Creating and using Python Virtual Environments
Windows users
These instructions are mostly for Linux or MacOS. If you are windows there are other options such as AnaConda. You also have problems with integrating with various windows IDEs. If you are using windows then maybe these instructions are useful.
In a lot of my courses I encourage students to use python virtual environments. Virtual environments are a great way of making sure that you have the correct version of packages installed. This is very short cheat sheet on how to set them up. I will assume that we are using python 3. Luckily python 3 has virtual environments set up. It is all in the documentation, but then sometimes people are too lazy to google, or do not know what to google for.
To create a virtual environment in the current directory do the following
If you look in the directory you’ll see a sub-directory env this
contains all files that drive the virtual environment. In particular
there is a sub-directory env/bin/
The most important file is the activate script. To start your
virtual environment you simply do
This executes the activate script. Notice that you prompt has changed
to (env)
You are now free to install what ever packages want. For exampe
Once you have done all your python goodness you should leave your virtual environment.