Mac python2.7 cannot be removed, because many system modules rely on, so we use pyenv to install the python3.6 version, so that can coexist.
1. Install OS X's Suite manager (like Ubuntu Apt-get),
The website is as follows: http://brew.sh/index_zh-cn.html
Or install directly with terminal commands
/usr/bin/ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
2, install PYENV, command as follows:
Brew Update
Brew Install Pyenv
VI. bash_profile
Add the following content:
Export pyenv_root=/usr/local/var/pyenvif which pyenv >/dev/null; Then eval "$ (pyenv init-)"; Fi
source. bash_profile
3. Install Python
Now we can look at the version of Python that can be installed
Pyenv install-l
We choose to install the latest 3.6.2
Pyenv Install 3.6.2
The database needs to be updated after installation is complete
Pyenv Rehash
To view the installed version of the system:
Pyenv versions
* Indicates the version currently being used by the system and can be seen on
Python view discovery is still version 2.7
Toggle Python Version
Pyenv Global 3.6.2
Pyenv versions
Confirm that the Python version is switched
Enter Python to use the new version of Python;
The system comes with a script that calls the old version of Python directly in a/usr/bin/python way, so it doesn't affect system scripting.
This article is from the "Adrenaline" blog, please be sure to keep this source http://lizitong.blog.51cto.com/12914119/1968592
Python multi-version coexistence and switchover using pyenv under Mac