Running PyAims scripts

AIMS library and commands usage

Moderators: denghien, riviere

Post Reply
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Running PyAims scripts

Post by riviere »

We were recently asked about the way to setup and use PyAims in practical life from a binary package of BrainVisa.
Forrest Sheng Bao kindly wrote a little doc here: http://forrestbao.blogspot.com/2011/08/ ... linux.html.

1. Actually, the binary package includes a full python interpreter (and also IPython and many popular modules), which is setup and compatible with the compiled libraries and modules in the package. So the easiest way, and safest, is to run the python or ipython command in the bin/ directory of the package: it will be able to use directly pyaims.

2. If for some reason you need to stick with the system python on your linux distribution, there are some environment variables to set:
- LD_LIBRARY_PATH shoud point to the lib/ directory of the package
- PYTHONPATH shoud point to the python/ directory of the package
- BRAINVISA_SHARE shoud point to the share/ directory of the package
- optionally, PATH may point to the bin/ directory of the package (but it's only needed if you have to run some commands from the package).
*BUT* in that case expect some binary incompatibilities between your system python and the compiled libraries of BrainVisa: as they have been compiled on different linux distributions / versions, lots of things may be slightly (and possibly unnoticeably, at first sight) different.
Be also aware that setting the lib/ directory of the BrainVisa package in your LD_LIBRARY_PATH will make libs from the package used before your system libs, which may lead to system commands not running anymore, and possibly break your system (from your account), so we discourage setting it in your ~/.bashrc, unless you are using the exact same system as the one brainvisa was built on (that is, Fedora 4 for 32 bit packages, or Mandriva 2008 for 64 bit packages). We still hope to be able to provide Ubuntu packages one day...

3. In the binary packages, you will also find a bin/bv_env command which sets up the environment for BV. You may use it with no arguments to see how the environment will be altered, or provide a command to execute as argument, for instance:

Code: Select all

brainvisa/bin/bv_env anatomist /data/mesh.gii /data/mri.nii
An alternative version of it is used to setup the environment in a shell: bin/bv_env.sh for bash shells for instance:

Code: Select all

% . brainvisa/bin/bv_env.sh
% ipython
>>> from soma import aims
Note that in this situation, you are as in case 1: ipython is the one from the binary package then.

If you have trouble with solution 2, and still need to use the system python, then the best option is to recompile aims/pyaims: see http://brainvisa.info/repository.html for that.

Denis
Post Reply