Multiple versions of Python coexisting in the same OS

Edward Diener eldiener at tropicsoft.invalid
Sun Jul 25 17:09:00 EDT 2010


On 7/25/2010 3:32 PM, Thomas Jollans wrote:
> On 07/25/2010 09:19 PM, Edward Diener wrote:
>> On 7/25/2010 10:03 AM, Thomas Jollans wrote:
>>> On 07/25/2010 02:46 PM, Edward Diener wrote:
>>>> The problem with this is that you forget that a script can invoke Python
>>>> internally. So whether one uses the console or file association method
>>>> of invoking Python externally, any already written script can use either
>>>> internally.
>>>
>>> Maybe it's just me, but I think that a script that does this is quite
>>> simply badly written: it *will* break on systems that have multiple
>>> Python versions.
>>
>> Whether it is badly written or not in your opinion it is legal and
>> happens all the time. Are you going to refuse to use any script, no
>> matter for what library or for what purpose, that internally invokes
>> Python either through a 'python' command or through a file with a Python
>> extension ? And how would you find out if a script did this or not ? Are
>> going to search every script in every distribution and library to
>> determine if it does this ? And when you find out a script does this,
>> what will you do ?
>>
>> Be real. saying you do not like scripts that internally invoke Python
>> does not solve anything if you have multiple coexisting versions of
>> Python installed.
>
> I doubt many scripts do it. The fact of the matter is: many systems have
> multiple Python versions installed in parallel, and it probably will
> break somewhere, which will get noticed, and probably fixed.
>
> If a script uses sys.executable instead of "python", there is no
> problem, at all.

What a script uses to internally invoke Python I can not control. My 
solution seeks to be non-intrusive and lets me run a particular version 
of Python, among the co-existing versions installed, at any given time. 
I believe that is the best I can do. I neither can control, nor do I 
want to control, all of the Python scripts installed on my system, nor 
can I worry how they may internally invoke Python. But I do want to be 
able to say, at any given time, that when I run Python a particular 
version, amidst the co-existing ones on my system, needs to be executed 
and therafter all internally executed modules use that version.

Trying to make rules for scripts, such as telling scripts they must use 
sys.executable, is pursuing an imaginary solution that can not work 
unless one is theoretically willing to manually inspect and change all 
Python scripts in some way. To me any intrusive changes to actual 
scripts is no solution at all.



More information about the Python-list mailing list