Roel Schroeven wrote: >Laszlo Zsolt Nagy wrote: > > >>[EMAIL PROTECTED] wrote: >> >> >> >>>I've got a trouble, and i think that anybody there can help me >>> >>>I've got a python script which i distribute in somes packages for *nix. >>>This script is full of python and need python 2.4 ! And i'd like to >>>display a message when the user doesn't have a python2.4 version. >>> >>> >>> >>> >>>>>import sys >>>>>sys.version >>>>> >>>>> >>'2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]' >> >> > >Yes, but the problem is also that Debian (not only Sid, but also stable >and testing) has python 2.4 but it is not the default, i.e. >/usr/bin/python is a symlink to /usr/bin/python2.3 even if >/usr/bin/python2.4 is available to. > > Hmm.
Idea one: Create a list of possible locations. First of all, use your PATH, and then add common locations: ['/bin','/usr/bin','/opt/bin','/usr/local/bin'] # etc. Then use a list of the possible executable names: ['python','python2.3','python2.4'] # etc Finally using these combinations, execute each executeable with python -V and examine its output. This may work, but I'm affraid there is no general solution. The system administrator can install different python versions to virtually any location. But I don't think you should be affraid of that. If a system admin installs different versions into strange locations, then he will take the responsibility to fix python programs that need a specific version. But in most cases, looking for a python executable on your PATH should be enough; and it is the most I would expect from an application. :-) Last idea: - create a configuration file that resides beside your Python program - take the path to the good executeable there - if the program was started with the wrong version, but you have the path to the good one (from the config file), then re-execute - otherwise print an error message telling the required version AND how the user can set it up in the config file Third idea (for Windows only): read available versions from the registry. ;-) Best, Les -- http://mail.python.org/mailman/listinfo/python-list