Trying to install python3 but terminal keeps showing as python 2.7.13 [duplicate]

拈花ヽ惹草 提交于 2020-01-04 05:45:10

问题


I have 2.7.13 on macOS Sierra and I'm trying to upgrade to python3 via

brew install python3

everything seems to have went fine except the last part:

==> 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

after that I type

python

and I get

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.

I'm pretty new to coding so any help is appreciated!


回答1:


Python 2.x and Python 3.x have different terminal commands.

Use command : python3 to use python 3.x

Similarly, use pip3 for installing python modules.


Note : Also try to learn virtualenv (virtual environments), so that you can keep your python 2.x and python 3.x environments separate.

There are many tutorials to do this, one such is this tutorial.



来源:https://stackoverflow.com/questions/43206751/trying-to-install-python3-but-terminal-keeps-showing-as-python-2-7-13

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!