-
Notifications
You must be signed in to change notification settings - Fork 0
How to Set up Python Virtual Environments
IN DEVELOPMENT - NOT READY FOR USE
Setting up a Python Virtual Environment is helpful for several reasons. An isolated environment avoids conflicts with Python packages used by other programs on the users system. Also, virtual environments allow the user to choose which version of Python they want to run on and to easily switch between versions.
It probably is already there, but Django 1.8 (needed by mtt console) does not support all versions. Check to see which versions of Python are available on your system. You will need Python version 2.7 or Python 3.3+ to run the console.
MTT requires the following packages, or their equivalents for your system, to work with both Python 2 and 3:
- libpq-dev
- python-dev
- python3-dev
- python-psycopg2
- python3-psycopg2
- automake
- libtool
- flex
- python-pip
Install the following packages using: $ pip install
- future
- virtualenv
- virtualenvwrapper
Add the following lines to .bashrc or your equivalent (.bash_profile for mac os-x for example):
source /usr/local/virtualenvwrapper.sh
export WORKON_HOME=$HOME/virtualenvs
Your specific paths may vary.
To create your new environment enter:
$ mkvirtualenv -r pyenv.txt --python=/usr/bin/(python of your choice) yourEnvName
It is not necessary to include --python=. The default is the systems Python (type: python -V to check your default version).
To see a list of available virtual environments use:
$ workon
To switch between environments type:
$ workon yourEnvName
To exit a virtual environment type:
$ deactivate
Before making a new virtual environment be sure to deactivate the environment you are currently in as shown above.