Installing the Python version management tool--pyenv
git clone git://github.com/yyuu/pyenv.git ~/.pyenvecho ' export pyenv_root= ' $HOME/.pyenv "' >> ~/.bashrcecho ' Export path= "$PYENV _root/bin: $PATH" ' >> ~/.bashrcecho ' eval "$ (pyenv init-)" ' >> ~/.bashrcexec $SHELL-L
View the version of Python that you can install by following this command:
Pyenv Install--list
After viewing the good version, I chose to install 3.6.5, but before installing it, we had to install the dependent packages required by Python, otherwise the installation would fail.
sudo apt-get install Libc6-dev gccsudo apt-get install-y make build-essential libssl-dev zlib1g-dev Libbz2-dev Libreadlin E-dev Libsqlite3-dev wget Curl LLVM
Once the above dependencies are done, we can install Python:
Pyenv Install 3.6.5-v
The command downloads python's source code from GitHub, extracts it to the/tmp directory, and performs the compilation work in/tmp. If the dependent package is not installed, a compilation error occurs and the command needs to be re-executed after the dependent package is installed. After the installation is complete, update the database with the following command:
Pyenv Rehash
To view the currently installed Python version:
Pyenv versions
* system (set by /home/yourname/.pyenv/version)
The two are returned, which means that the 3.6.5
*
python version being used by the current system is the system's own. To set the global Python version:
PYENV Global 3.6.5pyenv versions
system
* 3.6.5 (set by /home/yourname/.pyenv/version)
Install pyenv under Ubuntu to manage multiple versions of Python