Setup python environment with Anaconda - presemt-ntnu/transglobal GitHub Wiki

Quick start

  1. Install the Anaconda Python distribution. It satisfies almost all of the dependencies for Transglobal. It is freely available for academic use, for both Mac OS and GNU-Linux.

  2. Run the script env/setup_python_env_anaconda.py to setup a virtual Python environment containing all packages required by Transglobal.

  3. Source activate_anaconda.sh to activate the Python environment and to set the required shell environment variables:

$ source activate_anaconda.sh 

You need to activate the environment like this each time you want to use Transglobal. To leave the environment, issue the command

$ source deactivate 

Background

env/setup_python_env_anaconda.py creates a virtual Python environment in $HOME/anaconda/envs/transglobal. The pip Python installer is then called to install some additional packages that are not available as Anaconda packages.

activate_anaconda.sh activates the transglobal virtual Python environment. 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 the PATH env var
  • adds $TG_BASE_DIR/lib dir to PYHONPATH env var

If you work from an IDE and you do not use activate_anaconda.sh, make sure to use the Python interpreter in $HOME/anaconda/envs/transglobal/bin/python, to define the TG_BASE_DIR variable and to extend the PYTHONPATH variable.