0

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?

gvo
  • 101
  • Can you do ls -l /usr/bin/python{,2,3}? I am curious what they are symlinked to. – edwinksl Oct 05 '16 at 12:46
  • lrwxrwxrwx 1 root root 9 mars 20 2015 /usr/bin/python -> python2.7 lrwxrwxrwx 1 root root 9 mars 20 2015 /usr/bin/python2 -> python2.7 >lrwxrwxrwx 1 root root 9 mars 20 2015 /usr/bin/python3 -> python3.4

    – gvo Oct 05 '16 at 12:49
  • 3
    Do you have an alias defined for python? what does type python say? – steeldriver Oct 05 '16 at 12:50
  • I have : python is aliased to `python3'. That would explain why it goes looking for a python3 somewhere else! – gvo Oct 05 '16 at 12:52
  • Once the alias removed it works, thanks for the help, I didn't knew about aliases. If you want to add it as answer I will accept it. – gvo Oct 05 '16 at 12:58
  • Sidenote : you can use which command to find which command is aliased or linked to which file. for instance which python2 returns /usr/local/bin/python2 on my system. – thuyein Oct 17 '16 at 13:27

0 Answers0