Creating a Python Virtual Environment
by Ryan Angelo
The following steps allow for a user to create a Python virtual environment. This allows a user to have one or more Python environments where different package combinations can be installed without affecting your system installation of Python.
pip is a python package manager. See if you already have pip:
If you don’t hve pip, you can download and install pip
The virtualenv package allows you create the virtual environments. Install it with pip:
pip install virtualenv
Create a Virtual Environment
Create a virtual environment by specifying a path where you would like the installation to live. Example:
This will give us a separate python installation with its own packages that can be activated and used separately from the system Python installation.
Activate a Virtual Environment
We can activate the python environment:
Any Python commands that are run while using this terminal will be using the virtual environment that we just created, and will have any libraries that we subsequently install while having this environment active.
Deactivate a Virtual Environment
To stop using the virtual environment, returning us to the system environment we can simply: