Python Virtual Env

1.Check taht venv is installed

python -m venv

If it isn’t install it

pip install --user virtualenv

2.Create your virtual env

python -m venv  [project name] 

If you get the following error

Error: Command ... -Im, ensurepip, --upgrade, --default-pip returned non-zero exit status 1.

Exclude pip from your environment and install it separately : More info

python -m venv --without-pip [project name] 

source [project name]/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python   
deactivate
source [project name]/bin/activate

3. Activate your environment

source [env]/bin/activate

Check that your python is now the one that is in your environment

which python

4. Deactivate your environment

deactivate
comments powered by Disqus