Virtual Environment
Make virtual environment
$ pip install virtualenv
$ virtualenv mypython
Start virtual environment
$ source mypython/bin/activate
Deactivate virtual environment
$ deactivate
Start virtual environment in Python3
$ virtualenv -p python3 <envname>
Environment variables inside virtual environment
$ vi .env
>> Type your environment variables in this file (VAR=VALUE)
$ pip install python-dotenv
Switch python version in virtualenv
Use case: Some dependencies are not supported by Python3.8 yet.
$ virtualenv --python=/usr/bin/python<version> <path/to/new/virtualenv/>
# To find path for python (it's not always /usr/bin/...):
$ which python<version_number>
Last updated
Was this helpful?