[Tutor] Wrong version of Python being executed

Martin Walsh mwalsh at groktech.org
Sun Nov 11 23:57:01 CET 2007

Tony Cappellini wrote:
> Martin Walsh mwalsh at groktech.org
> Sun Nov 11 06:13:10 CET 2007
>>> That is odd.
>>> Try using the full path to python, just to be sure: c:\python25\python
>>> script.py -- do you get the same behavior?
> This works just fine- I would expect it to.

Actually, I would have expected the opposite. My initial thought based
on your description was that python2.5 is being invoked with PYTHON* env
vars from a previous install, or some site module weirdness. But, the
fact that running python.exe with it's full path corrects the issue,
seems to indicate a problem with your PATH, rather than any python
specific environment setting. What does 'set PATH' report?

Though this still doesn't explain why you get python2.5 interactively,
and python2.3 when running a script -- perhaps I'm still unclear what
you are seeing. Would the following be an accurate description of the

- you run inside a fresh 'cmd' console each time (typing 'cmd' at the
run dialog, or similar), to be sure there is no app environment kruft

- the current working directory doesn't contain any programs, scripts or
possibly links that could interfere (preferably an empty path)

- you don't have any PYTHON* environment vars set (including PYTHONSTARTUP)

you observe:
- when you type 'python' (only 'python') at the prompt, you get
python2.5 interactively

- when you use the form 'python script.py', the script is run with
python2.3 (can you verify with sys.version?) with sys.path appropriate
for 2.3

- when you use the form 'c:\python25\python.exe script.py', the script
is executed with python2.5 and you have the correct sys.path (for 2.5)

>>> Also, if you haven't already, you can run python with the -E and/or -S
>>> flags (ex. 'c:\python25\python -E -S script.py'). The -E flag will cause
>>> the PYTHONPATH and PYTHONHOME environment variables to be ignored. And
> This also works just fine. I've tried both switches independently, and
> the scrip runs normally when I use either and both at the same time.
> If I don't use them, then Python2.3 is being invoked somehow.

Yeah, very odd indeed.

 > Very strange indeed. It's starting to remind me of an episode from The
> Twilight Zone ;-)
> Is ti possible that my registry is corrupted?

I wouldn't think so, but I suppose it is possible. I believe all the
pertinent registry keys are store under
"HKLM\Software\Python\Pythoncore\<version>", so you could have a look.
There are settings stored elsewhere, but I think they are all related to
file associations, and enabling double-click launching etc. I hope
someone will correct or clarify, if I'm wrong.

If it is a registry issue, re-installing python2.5 *may* provide a quick
fix. BTW, are you using an alternate distribution of python (ex.
ActiveState), or the standard python.org version?


More information about the Tutor mailing list