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