Multiple versions of Python coexisting in the same OS

Edward Diener eldiener at tropicsoft.invalid
Sat Jul 24 22:46:14 EDT 2010


On 7/24/2010 6:25 AM, Mark Lawrence wrote:
> On 24/07/2010 04:17, Edward Diener wrote:
>> Are there any documents about multiple versionsof Python coexisting in
>> the same OS ( Windows in my case ) and what pitfalls to look out for ? I
>> have already run into a number of them. I installed Python 2.7 and 3.1.2
>> into completely folders, but immediately ran into serious problems
>> executing a Python script.
>>
>> The first problem is that just invoking Python will start whichever
>> version is first in the PATH, and this is true from the command line or
>> internally in a Python script.
>>
>> The second problem is that invoking a script ( some xxx.py ) will start
>> whichever version of Python is associated with the .py extension.
>>
>> The third problem is if some software expects its scripts, which it puts
>> in some Python subdirectory to be in the PATH.
>>
>> There may be other considerations but overall having to versions
>> coexisting has turned out to be a big headache involving both changes in
>> the PATH and in the .py association.
>>
>> Does anybody know of other things to look out for ?
>
> I found this only yesterday and found it extremely helpful, find the
> post by Gabriel Genellina.
>
> http://www.eggheadcafe.com/software/aspnet/35716114/maintain-2-versions-of-py.aspx

I found the solutions too exotic for actual use, and completely 
ineffectual for the cases I originally cited. The people in that thread 
seem to have completely forgotten that Python can be invoked externally 
and internally both through executing 'python(w) xxx' and through 
executing a file with the file extension(s) associated with Python. They 
seem to have forgotten this can be within scripts or any other program 
using Python, both written by themselves and by others, and not just by 
their typing 'python(w) xxx' somewhere. Their solutions seem to believe 
that only they will externally be i9nvoking Python and only for their 
own written scripts, as opposed to the many libraries using Python as 
well as the Python distribution itself.

The best solution is some program which changes the PATH and the Python 
file type associations depending on which version of Python one wants to 
use on one's own system when more than one Python version must coexist 
with others. I will probably write such a program for myself.

Are the .py and .pyc extensions the only ones which are associated with 
Python or are there others, for a normal Python installation in Windows ?



More information about the Python-list mailing list