Multiple python versions – Anaconda create virtual environment

Install Anaconda on Linux – Last post we saw how to install Anaconda in Linux.

Now lets see how to create multiple python versions on same machine using Anaconda and using them with any compatibility issues.

Creating a new python version:

  • conda create –name <> python=<>
  • E.g : conda create –name py36 python=3.6

Using particular Python version:

There are multiple ways you can use the desired python versions.

  1. source activate <>
    • This activates the desired python env and you can install any python packages which reflects only for the activated version.
    • Also any python code you execute will use the activated version.
    • To exit this virtual env, type : source deactivate <>
  2. You can invoke directly from installed directory like below:
    • /opt/anaconda/py36/bin/python – (This invokes python 3.6)
  3. Add to PATH environmental variable and add inn bashrc:
    • export PATH=/opt/anaconda/py36/bin:$PATH
    • After adding to bashrc, type : source ~/.bashrc

List Installed Python Versions:

  • conda list

How To Install Anaconda on Linux (Ubuntu, CentOS, Fedora) – Multiple Python versions on same machine

Download Link : https://repo.continuum.io/archive/Anaconda2-4.3.1-Linux-x86_64.sh

Instructions:

  1. Download the appropriate installer in the above links
  2. Execute the following bash Anaconda<<version>>-Linux-x86_64.sh
  3. Follow the instructions and complete the installation process

Testing Anaconda installation

Alright, we are done with the installation of Anaconda, let’s see how to verify that it is working as desired, run following command on your terminal and it should show output as list.

  • conda list

You can update the installed conda / anaconda packages by using following command.

  • conda update conda

In order to uninstall Anaconda, you need to remove its installation directory completely.