pyenv manages different python distributions

1. install

refer to official site: official

install via homebrew on osx or use pyenv-installer on linux.

2. add to .bashrc

add the corresponding line into .bash_profile, making it proceed the $PATH variable.

3. install different distributions

pyenv install --list # show the possible distributions
pyenv install 2.7.11
pyenv install 3.5.1
pyenv install pypy5.1

4. choose corresponding env

different env affects the python / pip commands, in the order:

pyenv shell 2.7.11 # use the dist. for current shell session
pyenv local 2.7.11 # use the dist. for current dir and all sub dir
pyenv global 2.7.11 # use the dist. for all 


  • shell: pyenv exports a shell variable
  • local: pyenv write a .python-version file in the current dir
  • global: pyenv writes a global version file $PYENV_ROOT/version
    • ~/.pyenv/version for linux
    • /usr/local/var/pyenv/version for osx

to remove:

pyenv shell --unset 
pyenv local --unset

5. packages

after changed to every new dist., pip is new and packages will be installed into that dist., for example:

add to path search for local 2.7.11 packages (??)

6. virtualenv

pyenv-virtualenv into

use barely virtualenv is ok

while pyenv could help to manage virtualenv in versions dir

pyenv virtualenv 2.7.11 myenv # create
pyenv virtualenv env2 # create under the current dist.
pyenv activate env2
pyenv deactivate
pyenv uninstall myenv #remove