Python
Virtual environments
Section titled “Virtual environments”Virtual environments are essentially local environments for Python so that you don’t install packages globally. It also lets you freeze version numbers so that you’re getting the same environment every time.
- To create one:
python3 -m venv venv- This will make a
venvfolder, which you should add to your.gitignorewith avenv/line.
- This will make a
- To use one:
source venv/bin/activate- After doing this, all of your installations will go into the local environment, e.g. packages will be installed in something like
venv/lib/python3.11/site-packages.
- After doing this, all of your installations will go into the local environment, e.g. packages will be installed in something like