Python Virtual Envs

From XPUB & Lens-Based wiki

Python virtual environments consists of a self-contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages.


set the venv by

  • opening the terminal in the python project directory
  • create the venv, with the python version you wish, we'll use 3.7
python3.7 -m venv ./venv 
  • activate the environment and should see (venv) in the shell prompt
source venv/bin/activate
  • now you can use pip to install or python to run the script, which will be always referencing to the python version you used to install the vev
  • later on when you wish to close the venv run: