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
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!
解决方案
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.