[Tutor] Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

boB Stepp robertvstepp at gmail.com
Fri Oct 10 14:43:47 CEST 2014


On Fri, Oct 10, 2014 at 2:05 AM, Wolfgang Maier
<wolfgang.maier at biologie.uni-freiburg.de> wrote:
> On 10/10/2014 05:57 AM, boB Stepp wrote:
>>
>> I am hoping to save other people the grief I just worked through. I
>> wanted to run both Python 2 and 3 on my windows PC, and, after
>> googling this topic found that with Python 3.3 or later one could
>> easily do both. So I merrily installed Python 3.4.2 first and then
>> Python 2.7.8. A Python 3 program that had been working fine suddenly
>> stopped working. After working down to a test portion of code that
>> isolated the culprit I realized my Python 3 program was being
>> interpreted by Python 2.
>
>
> It would help if you could share details about how you tried to run the
> Python 3 program (command line call, double-click, Python launcher for
> Windows, ..).
>
Initially, I ran the program in question by double-clicking on its
icon, which was my normal way of running it. This is when I realized I
had a problem. The program would run without error, but give erroneous
print and input statement results. I next put Python 3 into my path
variable, but the same error persisted. From the command line I found
that if I ran it normally (With Python 3 still in the path like it was
on my previous 3.4.1 installation.), meaning

python program_name.py

it behaved the same way as double-clicking on the icon. However, if I ran it as

py -3 program_name.py

then all was well.

Apparently Python 2.7.8 became the system default installation if I
installed it last, but after uninstalling both and installing Python
3.4.2 last, it became the default. Or, at least when double-clicked on
it ran normally.

I have since added shebang lines to my programs specifying Python 3.

I hope I have not forgotten any relevant details!



-- 
boB


More information about the Tutor mailing list