Python/virtualenv

From Omnia
Revision as of 22:05, 7 February 2023 by Kenneth (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

venv

Create virtual environment:

python3 -m venv [project_name]

This will create a folder called "[project_name]"

To use the folder:

source [project_name]/bin/activate

Then pip install whatever you want

To deactivate the virtual env: (from within the virutalenv)

deactivate

Ref: [1]

virtualenv

Pretty much identical but called using "virtualenv" instead of module

pip install virtualenv

Create env:

virutalenv [project]

Create env with particular python:

virtualenv -p $(which python2) [project]

Activate:

source [project]/bin/activate

Deactivate:

deactivate

Ref: [2]