
The goal is to install the virtualenv module to have each of the workspaces to run in their own virtual environment.
According to the official documents, "virtualenv is used to manage Python packages for different projects."
💡 WHY SHOULD I USE
virtualenv?
Well, using it helps you become more organized. Each of your projects might need different versions of python libraries. Having virtual environments for each of them therefore would be helpful in being more productive.
I am working on the Visual Studio Code on Windows 10:
- Python 3.11.1
- pip 22.3.1
virtualenv moduleInstall the module with the following code:
py -m pip install --user virtualenv💡 Since Python 3.3,
venvpackage is shipped together with the python itself and it serves the same purpose asvirtualvenv. However it only has a subset of features. You can find more int he official document here. It seems thatvirtualenvis still the more popular one as it supports both Python 2 and 3, so I think I'll keep to it for now.
Create the virtual environment in a workspace using the following code:
py -m venv env
# env is the location to create the virtual environmentActivate the virtual environment in the workspace using the following code:
.\env\Scripts\activate
# env here refers to the location where you created the virtual environment (refer to step 2)Deactivating is easy:
deactivateHoorah.
https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/
https://stackoverflow.com/questions/41573587/what-is-the-difference-between-venv-pyvenv-pyenv-virtualenv-virtualenvwrappe
https://towardsdatascience.com/why-you-should-use-a-virtual-environment-for-every-python-project-c17dab3b0fd0