Python steps to build a virtual environment

Source: Internet
Author: User
Tags virtual environment virtualenv
Preface

I believe it is normal for Python developers to have different versions of Python on the machine, since some of the projects are developed in 2.6 or 2.7, some with the 3.0+ version, how to manage these different versions, keep each environment clean and independent, and facilitate the switching between different versions. This is the time to use our virtual environment, so today we will look at the use of Python Virtual Environment Building tool PYENV.

1. Installation

git clone https://github.com/yyuu/pyenv.git ~/.pyenvecho ' export pyenv_root= "$HOME/.pyenv" ' >> ~/.bash_ Profileecho ' Export path= ' $PYENV _root/bin: $PATH "' >> ~/.bash_profileecho ' eval" $ (pyenv init-) "' >> ~/.bash _profileexec $SHELLsource ~/.bash_profile

Sign out and log on again.

2. Common commands

Pyenv install–list #列出可安装的 python version

Pyenv install-v 3.3.5 # installation 3.3.5 version

Pyenv Uninstall 3.3.5 #卸载

Pyenv version #查看当前版本

Pyenv Global 3.3.5 #切换到3.35 version

3, Installation Pyenv-virtualenv

git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv  Echo ' eval ' $ (pyenv Virtualenv-init-) "' >> ~/.bash_profilesource ~/.bash_profile

4. Create a virtual environment

Pyenv virtualenv 2.7.10 env2710

5. Activating the virtual environment

Pyenv Activate env2710

You can then install the required software in this environment.

6. Exit the virtual environment

Pyenv Deactivate

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.