Quick version
This tutorial focuses on creating a virtual environment or venv for use with Python. I only intend to provide a brief introduction to venv, mostly providing the code necessary.
To install the venv software enter the following:
pip install virtualenv
Now you can create a venv on your system. To initiate venv within any directory type the following:
python<version> -m venv <virtual-environment-name>
Like so:
python3 -m venv myVenv
To activate the venv enter the following command:
source myVenv/bin/activate
If on Windows type this command instead:
.\myVenv\Scripts\activate
Now you're all ready to use your venv. Just install software and dependencies as you normally would.
When you are ready to stop using your venv just type the following:
deactivate
And that's it. You can now use a virtual environment in Python. For more on venv in Python view the documentation here.
Top comments (0)