Running Python 2 and Python 3 on the same machine

Paul Watson paul.hermeneutic at gmail.com
Sat Dec 6 06:03:40 CET 2008


On Sat, 2008-12-06 at 01:27 +0100, "Martin v. Löwis" wrote:
> > For *NIX machines, will 'python' be placed into /usr/bin?
> 
> Not by default, no. Just try it and see for yourself.
> 
> Regards,
> Martin

Ok.  I built the source on an openSUSE 11.0 system.  I used 'sudo make
altinstll'.  It created an executable /usr/local/bin/python3.0 file.
Nothing was touched in /usr/bin.

I need to start writing some code with Python 3.  I want to write the
code in such a way that it can be easily shared with others with the
least difficulty and overhead as possible.  How should I write the code
to enable this?  What, if anything, should I assume about another
system's configuration?

As someone suggested before, naming the files as '.py3' is probably a
bad idea in the long run.  It also does not really solve the problem.

I could use a shebang.  But, what should it specify?  If I use
'python3.0', then that will soon be quite old.  If I make up a link for
python3 -> python3.0, that would work, but then every other system that
is to run the code must that link also.  However, I am thinking that
this would be the best long term answer.

    #!/usr/bin/env python3

My existing /usr/bin directory has three entires for python.

    python -> python2.5
    python2 -> python2.5
    python2.5

If I write scripts for Python 3, another developer writes scripts for
Python 2, and a common customer wants to install both of our packages
onto a single machine, then what is the best plan for everyone to make
that happen with as little difficulty as possible?

When we find out the answer to this, we can go back and talk about
Windows platforms.




More information about the Python-list mailing list