2

This is probably a windows problem and not a python one, but I'm stumped:

For most applications in my company we are constrained to Python 2.4.2. This isn't a problem for the most part, and my python 2.4.2 installation worked as expected.

The other day one of my colleagues was demonstrating a new utility he had created, which required python 2.5, so we installed python 2.5 and went through his demo.

When he was done I un-installed 2.5 and re-installed 2.4.2. That was when Python stopped parsing command line arguments.

If I run the command line below the supplied argument is not parsed:

C: \TEST >Template_Production_Test.py  pt_template.inipt_template.ini

Arguments: ['C:\\ TEST\\ Template_Production_Test.py']

The script scrolls through the contents of argv, and is clearly running as it is returning the script name rather than indicating program not found.

If I run the same script, but this time use the command line below:

C:\\TEST >python Template_Production_Test.py  pt_template.inipt_template.ini

Arguments: ['Template_Production_Test.py', 'pt_template.inipt_template.ini']

It all works.

I have no idea what is going on. I uninstalled everything and cleared out the folders, registry and environment variables, then re-installed from scratch. No change in behaviour.

Nobody in the company has seen this before. Anybody out there have any ideas?

Python 2.4.2, running on Win 7.

5
  • If I am reading it correctly, when you run the script without 'python' ahead of it, the script runs but does not acquire arguments past the first py filename. If you do write python ahead of the filename, everything is fine. Is this correct? Commented Oct 15, 2014 at 23:49
  • by arguments your referring the values in sys.argv? Commented Oct 15, 2014 at 23:53
  • Windows supports self-executing scripts? Is there a shebang line? Commented Oct 15, 2014 at 23:55
  • @DavidSanders: there is no shebang line; there are file associations between extensions like .py and applications like python.exe. Commented Oct 16, 2014 at 12:08
  • Why would you install python2.4 on anything? Commented Oct 16, 2014 at 22:08

1 Answer 1

2

Seems to be a duplicate. You should search in your registry using regedit.exe for C:\Python24\python.exe %1 and C:\Python25\python.exe %1. You have to modify the occurrences to C:\Python24\python.exe %1 %*.

With that you will fix two things:

  • wrong python paths
  • %* in the end passes the arguments again

Be aware of the right filepaths to python.exe in your specific case.

Sign up to request clarification or add additional context in comments.

2 Comments

None of my searches came up with the first posting. Anyway, I will try editing my registry and see if it sorts the problem.
%1 %* not just %*?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.