Managing multiple Python versions with multiple virtual environments

Since I was used to use rvm to handle multiple ruby versions, and a .ruby-version file which automatically switched version for me, of course I looked for something similar in the Python environment.

If you need to work with both Python2 and Python3 it’s a necessity in my opinion. Thanksfully, I don’t have to use Python2.

If you have a global (or system) version of Python installed, it’s usually located in /usr/bin/python (for python2) and /usr/bin/python3 (for Python3). Remember this if you think you are running the wrong version.


pyenv is the tool you use to maintain multiple versions of Python. You can find installation instructions here but I can recommend the pyinstaller.

pyenv install “shims”, which since they are ahead of the system python in the PATH will be executed. You can read all about how pyenv works here.

some commands you can use are:

  • pyenv versions (lists all pyenv-installed Python versions)
  • pyenv global 3.6.6 (selects version 3.6.6 as the global default version)
  • pyenv local 3.6.6 (selects 3.6.6 for this folder)

virtual environments

Virtual environments are used to keep “sets” of modules apart. In one project you might want a specific set of modules (with specific versions) and in another project you want another set. With a virtual environment you can keep them apart.


Most of the information in this article comes from:


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.