Install pyenv under Ubuntu to manage multiple versions of Python

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.