user8213812
user8213812

Reputation: 11

Where does ubuntu find python 3.6.8 instead of 2.7? What information should I refer to to understand the principle?

I don't know why I typed in python, ubuntu opened python 3.6.8, why should I open python3.6.8, how is the system looking for it?

/home/minzhang/anaconda2/bin/python
minzhang@minzhang:~/anaconda2$ /home/minzhang/anaconda2/bin/python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 19:04:19) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
minzhang@minzhang:~/anaconda2$ python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
minzhang@minzhang:~/anaconda2$ echo $PATH
/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/bin:/home/minzhang/anaconda2/envs/blockchain/bin:/home/minzhang/anaconda2/condabin:/home/minzhang/anaconda2/bin:/home/minzhang/bin:/home/minzhang/.local/bin:/home/minzhang/java/jdk1.8.0_181/bin:/home/minzhang/java/jdk1.8.0_181/jre/bin:/home/minzhang/work/exercise/gnuplot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin:/snap/bin:/usr/local/go/bin:/home/minzhang/go
minzhang@minzhang:~/anaconda2$ tail -n 2 /etc/profile

alias python=python3
minzhang@minzhang:~/anaconda2$ tail -n 2 ~/.bashrc
#export rsync_proxy=$http_proxy
alias python=python3
minzhang@minzhang:~/anaconda2$ python --version
Python 3.6.8 :: Anaconda, Inc.
minzhang@minzhang:~/anaconda2$ ll bin/python*
lrwxrwxrwx 1 minzhang minzhang     9 3月  10 10:34 bin/python -> python2.7*
lrwxrwxrwx 1 minzhang minzhang     9 3月  10 10:34 bin/python2 -> python2.7*
-rwxrwxr-x 1 minzhang minzhang 19760 12月 15 03:06 bin/python2.7*
-rwxrwxr-x 1 minzhang minzhang  1701 3月  10 10:34 bin/python2.7-config*
lrwxrwxrwx 1 minzhang minzhang    16 3月  10 10:34 bin/python2-config -> python2.7-config*
lrwxrwxrwx 1 minzhang minzhang    16 3月  10 10:34 bin/python-config -> python2.7-config*

“I expect the output of python to be 2.7, but the actual output is 3.6.8.”,

Upvotes: 1

Views: 71

Answers (3)

user8213812
user8213812

Reputation: 11

I found out, in the directory minzhang@minzhang:~/anaconda2/pkgs/python-3.6.8-h0371630_0/binbase environment

Upvotes: 0

Mitch
Mitch

Reputation: 3416

Because you have this alias python=python3 in your bash profile. An alias means when you type python you are actually calling python3. If you would like to call python 2 remove the alias from your bash profile

Upvotes: 0

Benjamin Striner
Benjamin Striner

Reputation: 467

Use which python and whereis python (where python on Windows) to debug questions about where executable files are being found. The output from those should answer your question. Cheers!

Upvotes: 1

Related Questions