Python multi-version management tool-pyenv, python tool-pyenv
Ubuntu System Version: 16.04
# Lsb_release-
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
Python version 2.7.12
# Python-V
Python 2.7.12
If you want to install version 3.x locally and coexist with version 2.x, you can use pyenv to manage different python versions.
1. Install pyenv
# Curl-L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
Install git locally. If there is no git locally, the installation will fail and a prompt will be given.
# Apt-get update
# Apt-get install git
After git is installed, install pyenv again.
2. Modify ~ /. Bashrc File
After pyenv installation is complete, vim changes ~ /. Add the following statement to the bashrc file:
Export PYENV_ROOT = "$ HOME/. pyenv"
Export PATH = "$ PYENV_ROOT/bin: $ PATH"
Eval "$ (pyenv init -)"
Restart Terminal
3. Install python
> View the python version that can be installed.
# Pyenv install -- list
2.7.14 # latest version of Python 2
......
3.6.4 # latest version of Python 3
......
Anaconda2-4.1.0 # support for Python 2.6 and 2.7
Anaconda3-4.1.0 # support for Python 3.3 and 3.4
......
2.7.14 and 3.6.4, this only version is python official version, other such as, anaconda2-4.1.0 is a derivative or release version
> Install python dependency packages
Under CentOS/RHEL/Fedora:
yum install readline readline-devel readline-staticyum install openssl openssl-devel openssl-staticyum install sqlite-develyum install bzip2-devel bzip2-libs
Under Ubuntu:
apt-get updateapt-get install make build-essential libssl-dev zlib1g-devapt-get install libbz2-dev libreadline-dev libsqlite3-dev wget curlapt-get install llvm libncurses5-dev libncursesw5-dev
> Install the specified version
# Pyenv install 3.6.4
> View the currently installed python version.
# Pyenv versions
* System (set by/root/. python-version)
3.6.4
The version after "*" is the current version of the system.
> Set the global python version.
# Pyenv global 3.6.4
# Pyenv versions
3.6.4
> Temporarily change the python version running in the system
# Pyenv local xxxx
Or
# Pyenv shell xxxx
> Other pyenv Functions
Pyenv uninstall xxxx // uninstall a version
Pyenv update // update pyenv and its plug-in