Python Virtual Environments

Virtual environments separate concerns, making sure that projects and their dependancies are isolated from one another. To start go ahead and make a directory where you want to place your Python environments in. Ill make a new directory and change to it:

mkdir myENVs && cd myENVs

Now that we are in the directory I want to use, we will go ahead and make a virtual environment using python 3.7

python3.7 -m venv prestonENV1


If we change directory to the new environment we just created and do a quick ls to show contents we find several files:

  • Rough breakdown of what is in the environment
    • bin – copy of py binaries and activate script is here too (see below)
    • include – package compilation
    • lib – holds 3rd party modules that are installed in the environment
    • pyvenv.cfg – config that points to the py installation that is used to create the environment


cat of pyvenv.cfg below:

contents of bin folder


You will now activate the environment by typing the following:
source prestonENV1/bin/activate

You can see the name of the env inline the prompt.


To exit the env simply type: