I believe that every python knows how to develop different python projects. sometimes, the python version is different and the software package version is different. The best solution to this problem is to build an independent python environment for different projects. Let's take a look.
Preface
I believe it is normal for python developers to have different python versions on the machine, because some development projects use 2.6 or 2.7, and some use 3.0 + versions, we need to use our virtual environment to manage these different versions, keep each environment clean and independent, and facilitate switching between different versions, so today, let's take a look at the use of python virtual environment setup 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
Log out and then log on.
2. common commands
Pyenv install-list # list installed python versions
Pyenv install-v 3.3.5 # install 3.3.5
Pyenv uninstall 3.3.5 # uninstall
Pyenv version # view the current version
Pyenv global 3.3.5 # switch to version 3.35
3. install 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. activate the virtual environment
pyenv activate env2710
Then you can install the required software in this environment.
6. exit the virtual environment
pyenv deactivate
For more information about how to build a virtual environment using python, refer to PHP!