Multiple versions of Python coexisting in the same OS

Edward Diener eldiener at tropicsoft.invalid
Sun Jul 25 08:46:56 EDT 2010


On 7/25/2010 6:07 AM, Gelonida wrote:
> Hi Edward,
>
> On 07/25/2010 04:40 AM, Edward Diener wrote:
>
>> 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.
>>
> Hi Edward,
>
> changing the path and is perfect for people who use consoles.
> (under linux there's virtuelenv for his and it's great)
>
> changing the file association is perfect for people who'd know at which
> time they want to use which version of python.

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.

>
> The usecase, that I'm nore aware of however is somethig like having some
> scripts / directories, that should use one version of python
> and others that shoud use another.
> In unix you do this normally with the 'shebang line'
> ( e.g.  #!/usr/bin/env/python2.6 )
>
> There the windows solution could be something like a small 'pystarter'
> program, which would decide depending on the file's location / the
> file's first line which python should be started.

This does not work when Python is invoked internally via a file 
association. That was the point of my saying that the simple solutions 
do not work.



More information about the Python-list mailing list