PYENV Introduction--debian/ubuntu Managing multiple versions of Python

Source: Internet
Author: User
Tags virtualenv

PYENV Introduction--debian/ubuntu Managing multiple versions of Python

may ST, 9:00am | COMMENTS

Pyenv is a tool for managing Python versions, and it supports switching between multiple Python versions.

First, install the pyenv
1
git clone https://github.com/yyuu/pyenv.git ~/.pyenv

Add PYENV_ROOT and pyenv init join Bash's ~/.BASHRC (or Zsh's ~/.ZSHRC)

123 
echo ‘export PATH=~/.pyenv/bin:$PATH‘ >> ~/.bashrcecho ‘export PYENV_ROOT=~/.pyenv‘ >> ~/.bashrcecho ‘eval "$(pyenv init -)"‘ >> ~/.bashrc
Second, the pyenv Common command list can be installed Python version
1
pyenv install -l

In addition to the official Python version, it also supports

    • Anaconda
    • IronPython
    • Jython
    • Miniconda
    • PyPy
    • Stackless
Install the specified version of Python
12
pyenv install 3.5.1pyenv rehash

It will automatically download and compile the specified version of the Python source code, which requires a system installation:

1
sudo apt-get install -y build-essential zlib1g-dev libssl-dev

You can also choose to install:

1
sudo apt-get install libsqlite3-dev libbz2-dev  libreadline-dev

After the installation is complete:

    • The source code (such as ~/python-3.5.1.tar.gz) is cached in the. Pyenv/cache directory and can be deleted manually after installation.
    • The Python version is installed in the ~/.pyenv/versions directory.
Uninstalling the specified version of Python
1
pyenv unstall 3.5.1
Set the Python version of the shell
1
pyenv shell 3.5.1

Equivalent to

1
export PYENV_VERSION=3.5.1

ClearPYENV_VERSION

1
pyenv shell --unset
Third, installation pyenv-virtualenv

Pyenv-virtual is a pyenv plug-in that supports managing multiple virtualenv

12
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenvecho ‘eval "$(pyenv virtualenv-init -)"‘ >> ~/.bash_profile
Create Virtualenv
1
pyenv virtualenv 3.5.1 aiohttp-virtual-env
    • Before you create a aiohttp-virtual-env, you must install the Python 3.5.1 (installed through the system or pyenv).
    • Aiohttp-virtual-env is stored in the ~/.pyenv/versions/3.5.1/envs directory, and a symbolic link with the same name is established in the ~/.pyenv/versions directory.
Delete Virtualenv
1
pyenv uninstall aiohttp-virtual-env
List virtualenv
1
pyenv virtualenvs
Activating/Disabling Virtualenv
12
pyenv activate aiohttp-virtual-envpyenv deactivate

PYENV Introduction--debian/ubuntu Managing multiple versions of Python

Related Article

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.