Python Virtual Environment

I have been using PyCharm for awhile and never really thought about having to contain my Python environments (sense it does it for you), but every once in awhile I need to work on a different IDE or a team member and I start scrambling for directions online.

The main reason why you would want to create a virtual environment is to limit your installed Python modules to your project.

Quick Ref: https://docs.python.org/3/library/venv.html

Creating virtual environments

python3 -m venv /path/to/new/virtual/environment

Activating a virtual environment

source env/bin/activate

You can confirm your virtual environment by typing the following

which python
.../env/bin/python # you should see this

Leaving the virtual environment

deactivate

Subscribe to Devtooler

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe