If you're using virtualenvwrapper
to manage your Python environments, it's easy to create environments that use specific versions of Python.
First, download the version of Python you need. On a Mac, the Python installer defaults to installing Python versions in the /usr/local/bin/
directory.
Then, use this command when creating a new environment:
$ mkvirtualenv -p [path/to/python/version] [name-of-environment]
The -p
flag allows us to specify what version of Python we would like to use. For example, if we want to create an environment called polls-tutorial
using Python 3.6.x, we would do so like this:
$ mkvirtualenv -p /usr/local/bin/python3.6 polls-tutorial
NOTE: The Python installer does not overwrite major versions — we can have 3.6.x and 3.7.x installed and use them in different environments. However! The installer does overwrite minor versions. So, if we have environments using Python 3.7.4 and then we install 3.7.6, any environments that were using 3.7.4 will now use 3.7.6.
Top comments (0)