Many Python scripts start with the following line:
#!/usr/bin/env python
On UNIX-like systems, this instructs the operating system to find the python executable according to the environment. To determine which version of Python gets run, just make sure that your PATH environment variable is set up correctly.
If Python 2.0 is installed as /usr/local/bin/python and Python 1.5.2 is installed as /usr/bin/python, and you want to run Python 2.0, then you should make sure that /usr/local/bin appears on your "path" before /usr/bin. How and when this is done depends a lot on your system and how you want to work.
Let's say you want to always use Python 2.0 as a particular user. This means that you need to edit your shell's resource file so that when it is started, it puts the directory in which Python 2.0 is found before the directory in which Python 1.5.2 is found.
Check your system documentation for details of which file you should edit and how you should edit it. Here's an example, though - for bash (the Bourne Again Shell), edit the .bashrc file in your home directory and add this at the end of the file:
export PATH=/usr/local/bin:${PATH}
This assumes that you did install Python 2.0 in /usr/local when considering MultiplePythonVersions.
If you just want to run AppServer with a changed environment so that only that program uses Python 2.0, and you are running bash, you can try this:
PATH=/usr/local/bin:${PATH} ./AppServer
Why not put this in a script:
#!/bin/sh PATH=/usr/local/bin:${PATH} ./AppServer
Don't be tempted to go round changing the first line of all Python scripts to something like this:
#!/usr/bin/env python20
If you do have Python 2.0 installed as something other than python then consider making a symbolic link from another directory to the executable, like this:
cd /usr/local/bin ln -s /usr/bin/python20 python
Now add that directory (in this case, /usr/local/bin) to the start of your "path", like we did above.
-- PaulBoddie - 31 Oct 2001