简体   繁体   中英

How to stop Python 2.7 running when "python3" is called in terminal?

When I run python3 in terminal, it states that I am running Python 2.7.10. I updated a pip package and conda package and since I have no way of running python3. I am sure python 2 is running as writing 'print "hello"' works which is should not, if python3 successfully ran.

Daves-MBP:Desktop dave$ python3

Python 2.7.10 (default, Oct  6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin

Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello"
hello

This should NOT work if python3 is running. How can I get python3 running when I want to? Do I need to set up the environment path, or something else?

Good news. I have solved the problem myself (using a different forum article) Setting the alias to the different python version in terminal solves this error.

$ alias python='python3.7'
$ alias python2='python2'
$ alias python3='python3.7'

So when I type 'python' in terminal, python3 is called. Not sure if my issue was an alias or path issue, as I was not aware of both concepts before I had the problem.

Make sure you have the python version installed before typing in python3.7 or 3.5 for instance.

Also, python3 alone does not work. Type python3.1 or python3.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM