Recommended for Yyuu/pyenv GitHub, which allows you to install as many Python versions as you like without modifying your system's own python, and that the versions are isolated from one another, and are easy to manage in multiple versions.
pyenvCan be used to manage and switch between different
pythonVersions, compared with virtualenv and Anacondo to create a virtual Python environment,
pyenvEasier and lighter to use. Installation
$ git clone git://github.com/yyuu/pyenv.git ~/.pyenv
Back ~/.pyenv is the address you want to install on the hard drive
Configuration
If you are using thebash
$ echo ‘export PYENV_ROOT="$HOME/.pyenv"‘ >> ~/.bashrc$ echo ‘export PATH="$PYENV_ROOT/bin:$PATH"‘ >> ~/.bashrc$ echo ‘eval "$(pyenv init -)"‘ >> ~/.bashrc
If you are using thezsh
$ echo ‘export PYENV_ROOT="$HOME/.pyenv"‘ >> ~/.zshrc$ echo ‘export PATH="$PYENV_ROOT/bin:$PATH"‘ >> ~/.zshrc$ echo ‘eval "$(pyenv init -)"‘ >> ~/.zshrc
After that, reload the shell
$ exec $SHELL -l
Use
View the version you are using now python
$ pyenv version
View the versions available for use by Pyenv python
$ pyenv versions
Installation python version
$ pyenv install <python版本>
The installed version will be in the ~/.pyenv/versions directory.
For larger version files, such as Anaconda, can be downloaded first to the official website, and then put the file in the ~/.pyenv/cache directory, and then execute the installation command, PYENV will not repeat the download.
In addition, you can use --list the parameters to view the version that can be installed
$ pyenv install --list
Uninstall will be install changed to uninstall line
$ pyenv uninstall <python版本>
Setting python a global version is generally not recommended to change global settings
$ pyenv global <python版本>
Set Local python version
$ pyenv local <python版本>
After setting, you can try or see the effect separately in the table of contents which python python --version , if not change, you can try $ python rehash again later.
Updatepyenv
$ cd ~/.pyenv$ git pull
Python Learning pyenv Tutorial