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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s