This article is an Anaconda installation guide and also a guide of its packages manager, Conda. With this technology we will be able to create development environment for Python and R with the libraries we prefer. It is very interesting to begin learn Machine Learning, data analysis and programming with Python.
Anaconda is a Free and Open Source distribution for Python and R languages. It is very used in Data Science, Machine Learning, Science, Engineering, predictive analytics,Big Data, etc
Installing Anaconda we can use a great quantity of packages. There are more than 1400 of the most known applications and software. Some examples are:
- Jupyter Notebook
- Numpy
- Pandas
- Tensorflow
- H20.ai
- Scipy
- Jupyter
- Dask
- OpenCV
- MatplotLib
- Scarapy
Some time ago I installed Keras and TensorFlow in my Ubuntu laptop without any environment, but the Anaconda solution seems to me easier and more useful.
Anaconda is a great option to install and work with Python in our OS. Is always a good practice to use environment development.
I am learning to manage big CSV in my work. I’m using Numpy and Pandas. And in many courses you have to use Jupyter Notebook. Everything is amazing, especially for begginers.
Anaconda vs Conda
Anaconda and Conda are not the same and you should not confuse them. Anaconda que es la suite que nos permite usar muchas librerías y software de Data Analysis, Science Data y Machine Learning con Conda que es el gestor de paquetes de Anaconda y de entornos virtuales.
How to install Anaconda in Ubuntu
We can install Anaconda in differents OS, Microsoft Windows, MacOs or Linux. I tell you my Ubuntu installation experience. Yes, I work with Ubuntu for more than 2 years.
Ther are many ways to install Anaconda in Ubuntu. My favourite one is go to official web and download .sh file. You have to search you OS and the version you prefer.
If you are a begginer I would choose 3.7 (3.x) because Python 2.7 (2.x) will be deprecated in a few years.
Well, download .sh file for linux (.sh files are as .exe for Windows), then open the console (Ctrl + Alt + t) and go to the directory where de file is.
Most common mistake in begginers is they don’t access to correct directory
Write
cd Descargas ls sh downloaded_file_name.sh
First line send us to Descargas directory (Descargas, yes, remember I am spanish, you will have Downloads or something similar). Second one “ls” list files in this directory, is te way to know our name file. Third is to execute .sh file.
It will begin to execute. Accept the different terms of the software license and say Yes/no to install Visual Code Studio. I said yes.
Things to do after install Anaconda
Close terminal window in order to get changes applied and re-open it. Then key in
cd Descargas ls sh downloaded_file_name.sh
anaconda-navigator
And you open a GUI as a navigator browser. We can install, uninstall activate or deactivate the different packages. You can do everything with command-line, of course.
Now we are going to check if all is right. We begin searching our conda version
cd Descargas ls sh downloaded_file_name.sh
conda --version
If is fine we get something like conda 4.6.4 if we see some warning or alert we will have to deal with them.
Search if there are any update.
cd Descargas ls sh downloaded_file_name.sh
conda update conda
conda update anaconda
This lines compare the last version with one we have installed. In the case that it find some update, the system ask us.
cd Descargas ls sh downloaded_file_name.sh
Proceed ([y]/n)? y
Type “y” and press Enter
How to create virtual environments with Conda
I am going to create a virtual environment called comparador
Write in Terminal or in Anaconda Prompt
cd Descargas ls sh downloaded_file_name.sh
conda create --name comparador python=3.7
Where comparador is the environment name and python=3.7 is the specific python version we want to install
Activate it
cd Descargas ls sh downloaded_file_name.sh
conda activate comparador
And deactivate it with
cd Descargas ls sh downloaded_file_name.sh
conda deactivate
Verifying virtual environments
cd Descargas ls sh downloaded_file_name.sh
conda info --envs
This, show us environments we have created. We get
cd Descargas ls sh downloaded_file_name.sh
# conda environments:
#
base * /home/nacho/anaconda3
comparador /home/nacho/anaconda3/envs/comparador
base is root, and the asterisk tells us that we have activated.
Activating an environment makes that we see the prompt with acvtive name environment in brackets.
More interesting commands:
Search applications. Imagine I want to install Keras, first I search for it ans its versions.
cd Descargas ls sh downloaded_file_name.sh
conda search keras
As I see that it is already installed
cd Descargas ls sh downloaded_file_name.sh
conda install keras
And to list everthing we have installed in our environment
conda list
How to manage packages pkgs with conda
Here some interesting options help us to set up our environment and packages we want or need to work.
To install packages
There are very specific commands. To install a package in a particular environment.
conda install --name comparador keras
If you don’t use –name comparador it would be installed in the active environment.
We can install multiple packages at once (keras y scrappy)
conda install keras scrappy
But it is not recommended to avoid dependencies problems
We can select the specific package version to install.
conda install keras=2.2.4
To install non-Conda packages
We use pip
pip install
To update packages
There are different options. To update a especific package with
conda update keras
To update python
conda update python
To update Conda itself
conda update conda
And to update the Anaconda metapackage
conda update conda
conda update anaconda
To remove packages
To remove a package in a specific environment. Example, remove Keras form comparador environment
conda remove -n comparador keras
To remove in your current environment
conda remove keras
And remove multiple packages at once
conda remove keras scrappy
It is recommended to check the packages to see if it has been successfully uninstalled
conda list
According to me all above commands are the basic ones. If you want to learn more here official conda userguide
Official Conda cheat sheet, with main commands for a fast use
A walk through the graphic environment of Anaconda
But if you don’t like Terminal, you can manage packages and environments with Anaconda GUI
Go to base(root) environment, if you don’t
conda activate base
And now you can call Anaconda
anaconda-navigator
I leave you a video, but I am speaking spanish, sorry.
With everything I have learned we can begin to invest and experiment with a huge quantitie of libraries, and packages.
If you have any questions leave a comment and I will try to help you