DEV Community

Adam Lombard
Adam Lombard

Posted on • Edited on

7 1

Python: Specify Python versions with virtualenvwrapper

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]
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post