Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How do I get Ubuntu to use Anaconda's python instead of previous Python installation?

Writer Andrew Henderson

I know that a very similar question has been asked there, but I think my issue is different.

I have just installed Anaconda2 following the Anaconda documentation steps (downloading and executing the sh script), then re launching the shell. I had a previously installed python version on /usr/bin, which was version 3.4.3. I have Ubuntu 14.04.5 LTS.

I have created an environment which should run on python 2.7

conda create --name myenvpy2 python=2
source activate myenvpy2

If I look at my path, I have the following

echo $PATH
/home/gvo/anaconda2/envs/myenvpy2/bin:/home/gvo/anaconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:...

On /home/gvo/anaconda2/envs/myenvpy2/bin I have the correct version of python

ls -l
python -> python2.7

And

./python --version
Python 2.7.12 :: Continuum Analytics, Inc.

Therefore, when running simply python I would expect the same result, since this folder contains a python and is the first of the $PATH variable. However :

python --version
Python 3.4.3

This effectively seems to be the /usr/bin version of Python

>>> import sys
>>> print (sys.executable)
/usr/bin/python3

I don't understand why, despite a python can be found in the first folder of the path, it goes through another version of Python, found in a later folder.

Please note that with a python=3 environment created and sourced, it indeed uses the correct python version installed by anaconda, which adds a lot to my confusion.

python --version
Python 3.5.2 :: Continuum Analytics, Inc.

Do you have any clue?

6 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy