Changes

Jump to navigation Jump to search

Multiple Python versions

2,476 bytes added, 16:46, 8 August 2013
Created a page about multiple Python versions
On certain systems, multiple Python versions may be present. Special care must be taken in such situations when running relax or when compiling the relax C modules.


== SCons ==

When multiple Python versions are present, the '''scons''' script used to [[Scons|build relax]] is always problematic. The reason is because the top of the script starts with:
<source lang="bash">
#! /usr/bin/env python
#
# SCons - a Software Constructor
#
</source>

This means that the script will look for Python in the PATH environmental variable (in Linux, Mac OS X, and MS Windows) and use that one rather than the Python it was installed for. There are two methods to overcome this difficulty.

=== Modifying the sources ===

The first is to edit the first line of this script to point to the correct Python version. For example if the Python you wish to use is installed in the /usr/local/bin/ directory, you could change this script to:<source lang="bash">
<source lang="bash">
#! /usr/local/bin/python
#
# SCons - a Software Constructor
#
</source>

=== Pointing to the correct version ===

Alternatively, if Python and scons are in /usr/local/bin, but you see:
<source lang="bash">
$ which python
/usr/bin/python
$ which scons
/usr/bin/scons
</source>

You can simply provide full paths when compiling the relax C modules:
<source lang="bash">
$ cd /path/to/relax/
$ /usr/local/bin/python /usr/local/bin/scons
</source>

The last command forces '''/usr/local/bin/scons''' to use the correct Python version.


== Running relax ==

When multiple Python versions are present, there are two ways to run relax with the correct version.

=== Modifying the sources ===

The first is to permanently modify the relax sources to use the correct Python. If you look at the top of the '''relax''' file, you will see:
<source lang="python">
#! /usr/bin/env python

# Import the relax module.
import relax

# Start relax.
relax.start(profile_flag=False)
</source>

If the wrong Python version is being used, then assuming the correct one is in '''/usr/local/bin/python''', change that file to:
<source lang="python">
#! /usr/local/bin/python

# Import the relax module.
import relax

# Start relax.
relax.start(profile_flag=False)
</source>

This will force the correct version.


=== Pointing to the correct version ===

The alternative is to simply run relax with:
<source lang="bash">
$ /usr/local/bin/python ~/bin/relax
</source>

This assumes that relax is installed in the home directory.
Trusted, Bureaucrats
4,228

edits

Navigation menu