bowo bowo - 1 month ago 14
Python Question

How to conveniently change from Python ubuntu native to Python Anaconda and vice versa?

I have Linux Ubuntu 16.04 with several versions of python installed.


  1. Python 2.7 Ubuntu native

  2. Python 3.5 Anaconda

  3. Python 2.7 Anaconda



The default for my terminal is (2), and I can easily switch to (3) with 'source activate' command. This is because I added the environment for (3) using conda after I have installed (2).

However, since (1) is linked to a PDE solver package (fenics) that I want to use from time to time, is there a practical way to set (1) as the default for a while? Is there any quick way to do it for example like when I changed (2) to (3) and vice versa?

Answer

I managed to get what I wanted by adding this line to .bashrc:

export PATH="/usr/bin:$PATH"

which give the location of (1). However, do not delete or commented out the path to the anaconda. Hence, I can access (2) by using:

source activate root

and can easily switch to (3) by:

source activate py27

Note: py27 is the name I gave to (3) environment when I installed it using conda.

Then, if I want to go back to (1), just use:

source deactivate
Comments