A quick starter on Python Virtual Environment
Create:
mkdir workingdir
cd workingdir
virtualenv venv
On Unix/Mac OS X use:
source venv/bin/activate
On Windows use:
venv\Scripts\activate.bat
Finish:
deactivate
To move the environment somewhere else:
- In existing (active) environment; grab a list of dependencies with
pip freeze > requirements.txt
- In new (active) environment; install from the dependency list with
pip install -r requirements.txt
To set a specific Python version. On Mac:
- First find the path to the version we want with
which python3
- Activate the environment and run
mkvirtualenv --python=<path to python> <venv>
For examplemkvirtualenv --python=/usr/local/bin/python3 myenv