Page 1 of 1

Using a custom Python installation

PostPosted: Fri May 27, 2011 12:48 am
by rguha
Hi, I'm in the process of installing OMERO 4.2 and the system python (/usr/bin/python) is 2.4. However I also have Python 2.6 installed separately - is it possible to indicate during installation that this version of Python be employed (and not the system version)?

Re: Using a custom Python installation

PostPosted: Fri May 27, 2011 6:09 am
by jmoore
There are several ways to go about doing this, only one of which is OMERO specific:

  • If the Python 2.6 executable is also named "python", then you should be able to add that to the front of your PATH environment variable to have it used, since OMERO simply looks for the first "python" executable. You may also need to modify your PYTHONPATH variable.
  • However, on most systems, the secondary python is named "python26" (or similar), in which case you could use virtualenv to setup a secondary Python installation. We have used this in several different cases with success, typically on CentOS boxes. (See listing 1 below)
  • Finally, if you would rather make the change to OMERO itself, you can modify which executable it looks for in the etc/grid/templates.xml file. Unfortuantely, this is copied in several places, so you'll have to replace all instances of exe="python" with the correct executable. You can use a variable to only have to make the change once, e.g. exe="${PYTHON}". I'll add the variable now to OMERO 4.3 to prevent other users from having to make the same change.

Hope that helps.
~Josh

Listing 1:
Code: Select all
$ python --version
Python 2.6.6
$ virtualenv --python=python2.5 /tmp/my_python2.5
Running virtualenv with interpreter /opt/local/bin/python2.5
New python executable in /tmp/my_python2.5/bin/python
Installing setuptools............................done.
$ source /tmp/my_python2.5/bin/activate
(my_python2.5) $ python --version
Python 2.5.5


Re: Using a custom Python installation

PostPosted: Fri May 27, 2011 11:54 am
by rguha
Thanks a lot!

Re: Using a custom Python installation

PostPosted: Fri May 27, 2011 11:59 am
by jmoore
Glad to help. Let us know if you have any problems, or what you think works the best.

Cheers,
~Josh.