Chris G
Chris G

Reputation: 115

Python not parsing command line

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.

Upvotes: 2

Views: 216

Answers (1)

wenzul
wenzul

Reputation: 4058

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.

Upvotes: 2

Related Questions