Anaconda Python installation and configuration on Ubuntu
Anaconda is an open source and free distribution written in Python. It was released in July 2012. It is cross-platform and supports many operating systems. Anaconda provides New BSD License. It is distribution of Python, R programming languages for data science and machine learning related applications. Anaconda has more than 6 million users. It is the fastest way to do R data science, Python and machine learning on Windows, Mac OS X and Linux.Anaconda helps the organizations to develop, manage and automate AI/ML. It empowers organizations for data science from laptop through training to production. It allows organizations to scale from individual data scientists to a collaborative group of data scientists and from a single server to thousands of nodes for model training and deployment.
Anaconda provides more than 1000 data packages, Conda package and virtual environment manager. This is called Anaconda Navigator. This eliminates the hassle to install each library independently. Anaconda Navigator is GUI (graphical user interface) based application which allows the users to launch applications and use them without using command line. Anaconda allows to create interactive visualizations based on data insights.
In this tutorial, I will be using Ubuntu 16.04. I will install and setup Anaconda Python.
- At least 3GB free disk space.
- 1GB RAM
- 1 Core Processor
- Registered domain name
- The domain must be pointed on your server IP address
- SSH client for command-line based distribution
- Server’s hostname should be set up.
- Create a user with root privileges.
- You may be interested in getting free SSL certificate for your domain name. (Optional)
Update System package:
Before proceeding with installation of any kind of package, use the following command to update your Ubuntu system. To execute this command, remember to login from non-root user with sudo privileges. After execution of this command, you will be prompted to Is this ok? Type ‘y’ and hit Enter key.
# sudo apt update && sudo apt upgrade
Download and install Anaconda Python:
To download and install Anaconda Python, I will recommend you to use Anaconda installer bash script. Bash script will automatically install the required libraries and packages. To do this, you will need to follow the steps below.
Navigate to directory /tmp, because after installation of Anaconda Python, you will no longer require the Anaconda installer bash script, so you may delete it.
# cd /tmp
To fetch latest version of Anaconda Python installer, you may check official website of Anaconda Python https://www.anaconda.com/download/#linux. Execute the following command to fetch Anaconda Python installer bash script.
Execute the following command to check either the file has been downloaded successfully. Also note the name of the file because it will be used for checksum in the next step.
# ls -li
Now you will need to verify data integrity of installer. To do so, you will have to use cryptographic hash verification through SHA-256 checksum. To do this, you will have to execute sha256sum command and use Anaconda3–5.2.0-Linux-x86_64.sh file name. In your case, file name may be different due to different versions of Anaconda Python.
# sha256sum Anaconda3-5.2.0-Linux-x86_64.sh
You will see the following output:
You can check the out by comparing hashes available at Anaconda Python page. http://docs.continuum.io/anaconda/install/hashes/
Now you will need to run the bash script. To do so, execute the following command.
# bash Anaconda3-5.2.0-Linux-x86_64.sh
You will see the following screen. Press Enter key to continue.
Now you will see — more on screen again and again. Keep hitting Enter key until you see “Please answer ‘yes’ or ‘no’”. Type ‘yes’ and hit Enter key.
Now you will see the following screen. Hit Enter key.
Now you will see the following screen. Type ‘yes’ and hit Enter key.
You will be asked to install Microsoft Visual Studio. In case, you are willing to setup Visual Studio, you will need to type ‘yes’ and hit Enter key for continuing.
Now the installation of Anaconda Python has been completed.
In order to activate installation, you will need to source the file using the command below.
# source ~/.bashrc
Now you may verify the installation by executing the following command.
# conda list
Settings for Anaconda Environments
You can keep projects in Anaconda virtual environments by organizing them on the basis of Python versions and packages. You can specify the version of Python for each Anaconda environment and keep all the related programming files together within that directory. You can check the available versions of Python by executing the command below.
# conda search "^python$"
Now you will need to create an environment. You can do so by using most recent version of Python 3. You can achieve this by assigning version 3 to Python. To assign version, execute the following command.
# conda create --name aareez python=3
Remember to replace aareez with your desired environment name.
If you want to target a specific version, you may use command by specifying version number as given below.
# conda create --name aareez python=3.7.0
After execution of the above command, you will see the following message where you will be asked for permission to install new packages. Simply type ‘y’ and hit Enter key to proceed.
After successful creation of environment and installation of required packages, you will see the following screen suggesting you the command to activate or deactivate created environment.
Each environment on creation installs some required default packages including:
You can also add additional packages if required. For example, if you want to install numpy, you will need to install the following command.
# conda install --name aareez numpy
Now next step asks you to permit installation of required packages. Type ‘y’ and hit Enter key. Now you have done with installation. You can activate environment by executing the command below.
# source activate aareez
If you want to install r-acepack in current environment, you can execute the following command to install r-acepack after activating your environment.
# conda install -c r r-acepack
Next step asks you to permit installation of required packages. Type ‘y’ and hit Enter key. Installation has been completed successfully. You may deactivate environment using the command below.
# source deactivate
You can verify the version of Python within the environment by using the command below.
# python --version
You can also update the version of conda by executing the command below within the environment.
# conda update python
You can also check the available environments by executing the command below. After executing the command, you will see the list of environments.
# conda info --envs
The asterisk (*) indicates the currently activated environment.
If you are willing to install any package during creation of environment, you may use the following command for creation of environment.
# conda create --name aareez python=3 numpy
When you have done working in an environment and no longer require the particular environment to work, you may remove this using the following command.
# conda remove --name aareez –all
You will see the following screen in which you are asked to allow to remove the other installed packages. Type ‘y’ and hit Enter key, environment named aareez will be deleted successfully.
To verify, you can again check the list of available environments by using the following command.
# conda info --envs
Keep updating Anaconda:
It is necessary to keep your Anaconda up to date to get the latest packages. To do so, you can execute the command below.
# conda update conda
You will be asked for permission to allow updating packages. Type ‘y’ and hit Enter key. The above command will update conda. After this execute the following command to update Anaconda.
# conda update Anaconda
This will ensure the use of latest version of Anaconda. You will be asked for permission to allow updating packages. Type ‘y’ and hit Enter key.
Congratulations! You have successfully installed Anaconda Python. You have also learnt to install various packages, update, remove, create and much more. Remember to keep Anaconda updated and don’t forget to share this tutorial on your social media.
Originally published at www.imarslan.com on February 24, 2019.