Multiple versions of Python coexisting in the same OS

Thomas Jollans thomas at jollans.com
Sun Jul 25 17:57:45 EDT 2010


On 07/25/2010 11:10 PM, Edward Diener wrote:
> On 7/25/2010 3:39 PM, Christian Heimes wrote:
>> Am 25.07.2010 21:32, schrieb Thomas Jollans:
>>> If a script uses sys.executable instead of "python", there is no
>>> problem, at all.
>>
>> It's true that sys.executable is the best way if you have to start a new
>> Python interpreter. However sys.executable may not be set for NT
>> services. So there may be a problem after all.
>>
> 
> Once you start instrusively changing scripts to find a solution to
> multiple versions of Python co-existing in one system, you are heading
> down a path of endless problems.

What exactly is it that you're afraid to change?

The standard library? There's certainly no need to change that in any way!

Your own code? That'd just be nonsense.

Someone else's then. Is there any problem at all when you start it with
a specific Python interpreter? I expect that there probably isn't. If
there is, if the code makes ANY assumptions about where to find a Python
interpreter on your system, I would consider that a serious bug that
should be reported. If it's only one or two affected lines of code, why
not change them? There's nothing intrusive or wrong about fixing
something on your own computer!
If it turns out that you'd have to change a lot of code to make it work,
THAT's the time to think about a complex workaround, like writing a
batch file that sets up an environment in which it works, for that
program. Otherwise, I don't think it's worth the effort.

I'm on a Linux system with multiple Python interpreters. (Almost) all
installed Python programs work with the system default interpreter
(CPython 2.6). Those that don't have been fitted with shebang lines like
"#!/usr/bin/python2.5". This tells the OS to use a different
interpreter, like the pystarter script solution proposed in this very
thread.



More information about the Python-list mailing list