Installing multiple versions of Python using pyenv

Source: Internet
Author: User

Pyenv is a tool that facilitates the use of multiple versions of the Python environment

Pyenv is written using shell script, only need to download to use, do not need root user, this I prefer.

Specific introduction to see the website: https://github.com/yyuu/pyenv

Let me explain the installation steps in detail

0. System Preparation

I use Ubuntu Desktop 14.04,

Default git is not installed, need to install

sudo apt-get install git

Some packages need to be installed, otherwise there will be an error when installing the Python version

sudo apt-get install libbz2

sudo apt-get install Libbz2-dev

sudo apt-get install Libssl-dev

sudo apt-get install Libreadline6 Libreadline6-dev

sudo apt-get install Libsqlite3-dev

First install I did not install the above package, reported the following error:

Warning:the Python bz2 extension is not compiled. Missing the bzip2 Lib

Warning:the Python readline extension is not compiled. Missing the GNU readline Lib

Error:the Python SSL extension is not compiled. Missing the OpenSSL Lib

If the Lib name is not confirmed, you can use sudo apt-cache search to find

1. Installing pyenv

Pyenv is a shell script that only needs to be downloaded and then specified environment variables.

git clone https://github.com/yyuu/pyenv.git/pythontest/.pyenv

echo ' Export pyenv_root= '/pythontest/.pyenv ' >> ~/.BASHRC

echo ' Export path= ' $PYENV _root/bin: $PATH "' >> ~/.BASHRC

Echo ' eval ' $ (pyenv init-) "' >> ~/.BASHRC

2. Install different versions of Python

Ready to install 2 latest versions

2.7.11

3.5.1

Use the following command to

Pyenv Install 2.7.11-v

Pyenv Install 3.5.1-v

Pyenv Rehash

Use pyenv versions to view your environment

If you need to delete the specified version:

Pyenv Uninstall x.x.x

3. Set the current environment, 3 different ranges

Pyenv Global 3.5.1

Pyenv Local 2.7.11

Pyenv Shell 2.7.11

Virtualenv Installation at 4.pyenv

Just go right down.

git clone https://github.com/yyuu/pyenv-virtualenv.git/pythontest/.pyenv/plugins/pyenv-virtualenv--where/pythontest /.pyenv is the directory where you install Pyenv

Exec "$SHELL"--Reload SHELL, update environment variables

Creating 351 environments

Pyenv virtualenv 3.5.1 env351

Enter the 3.5.1 environment

Pyenv Activate env351

Exit 3.5.1 Environment

Pyenv Deactivate

5. Delete the corresponding environment

Delete Directory

rm-rf/pythontest/.pyenv/versions/env271

Installing multiple versions of Python using pyenv

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.