In this video, we will be looking at virtualenv and why you should be using virtual environments in Python. Virtual Environments in Python allow us to keep project-specific dependencies in a separate place than our global site-packages. This is extremely useful when you have different versions of packages for different projects.
Here’s a brief walkthrough of some of the code from the video:
Install virtualenv
pip install virtualenv
Create a location for your environments (Optional)
mkdir ~/Environments
cd ~/Environments
Create a new virtual environment (called venv for this example)
virtualenv venv
Activate your new virtual environment
source venv/bin/activate
At this point you can work from inside of your new virtual environment and know that you are keeping your project-specific packages and dependencies separate.
When you are finished, you can deactivate your virtual environment
deactivate
If you no longer need your environment and would like to delete it, you can just remove the directory
rm -rf venv