Setup Python environment with Canopy - presemt-ntnu/transglobal GitHub Wiki
Quick start
-
Install the Enthought Canopy Python distribution, as this satisfies almost all of the dependencies for Transglobal. It is freely available for academic use, for both Mac OS and GNU-Linux. Otherwise use a standard Python version 2.7 installation.
-
Run the script
env/setup_python_env_canopy.py
to setup a virtual Python environment containing all packages required by Transglobal. -
Source
activate.sh
to activate the Python environment and to set the required shell environment variables:
$ source activate_canopy.sh
You need to activate the environment like this each time you want to use Transglobal. You can use the command deactivate
to leave the environment.
Background
env/setup_python_env_canopy.py
uses virtualenv to create a virtual Python environment in the directory env/_python
. It is not completely isolated but allows access to site packages, because some packages (e.g. Numpy and Scipy) can be hard to build and are easier to obtain through an OS package manager or a Python distribution like Canopy.
The pip Python installer is then used to install all packages specified in ´env/requirements.txt´, unless they are already provided in the global site packages.
activate_canopy.sh
activates the virtual python environment by sourcing env/_python/bin/activate
. In addition it sources env/setup_shell_env.sh
which
- sets env var
TG_BASE_DIR
to the root of the cloned repository - adds
$TG_BASE_DIR/bin
to thePATH
env var - adds
$TG_BASE_DIR/lib
dir toPYHONPATH
env var
If you work from an IDE and you do not use activate_canopy.sh
, make sure to use the Python interpreter in env/_python/bin/python
and to define the TG_BASE_DIR
and PYTHONPATH
variables.