试图安装python3但终端一直显示为python 2.7.13

时间:2017-04-04 12:04:50

标签: python homebrew

我在macOS Sierra上有2.7.13,我正试图通过

升级到python3
brew install python3

除了最后一部分,一切似乎都很顺利:

==> Installing python3 
==> Downloading https://homebrew.bintray.com/bottles/python3-3.6.1.sierra.bottle
######################################################################## 100.0%
==> Pouring python3-3.6.1.sierra.bottle.tar.gz
==> Using the sandbox
==> /usr/local/Cellar/python3/3.6.1/bin/python3 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python3/3.6.1/bin/python3 -s setup.py --no-user-cfg instal
==> /usr/local/Cellar/python3/3.6.1/bin/python3 -s setup.py --no-user-cfg instal
==> Caveats
Pip, setuptools, and wheel have been installed. To update them
  pip3 install --upgrade pip setuptools wheel

You can install Python packages with
  pip3 install <package>

They will install into the site-package directory
  /usr/local/lib/python3.6/site-packages

See: http://docs.brew.sh/Homebrew-and-Python.html
==> Summary
  /usr/local/Cellar/python3/3.6.1: 3,600 files, 55.8MB
之后我输入

python

我得到了

Python 2.7.13 (default, Dec 17 2016, 23:03:43) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

我对编码很陌生,所以感谢任何帮助!

1 个答案:

答案 0 :(得分:5)

Python 2.x和Python 3.x有不同的终端命令。

使用命令:python3来使用python 3.x

同样,使用pip3安装python模块。

注意:还要尝试学习virtualenv(虚拟环境),这样就可以将python 2.x和python 3.x环境分开。

有许多教程可以做到这一点,其中一个是this tutorial