Skip to content

Instantly share code, notes, and snippets.

@andmax
Created March 21, 2023 11:44
Show Gist options
  • Save andmax/0be4c2ee3a96b331beca63f2d4179889 to your computer and use it in GitHub Desktop.
Save andmax/0be4c2ee3a96b331beca63f2d4179889 to your computer and use it in GitHub Desktop.
Python virtual environments (venv) are good to:
1. Use a specific version of Python;
2. Do pip install rightly (without sudo);
3. Be able to use other Python versions as jupyter notebook run kernel.
It is the recommended way of organizing packages versions in Python 3.3+.
To create/activate/deactivate a venv:
python3.8 -m venv ~/python3.8-venv
source ~/python3.8-venv/bin/activate
deactivate
In an activated venv, install pip and then do pip installs, e.g.:
python3.8 -m pip install --user --upgrade pip
pip install opencv-python jupyter notebook
(It's a good package to have "import cv2" without compiling OpenCV.)
To install jupyter kernels, do:
ipython kernel install --name "python3.8-venv" --user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment