1

Good day,

I've experienced a few issues with a few Python applications not calling their dependencies correctly in Windows 7. These applications will call their Python dependencies directly instead of as an argument to python.exe. As opposed to changing each file in the dependency chain to call the python command first, is there any way to make a direct call to a Python file and pass the parameters correctly, or is this an incorrect call to Python?

Note: I have python.exe set as the default program for .py files

C:\Users\***>ftype | findstr -i python
Python.CompiledFile="C:\Python27\python.exe" "%1" %*
Python.File="C:\Python27\python.exe" "%1" %*
Python.NoConFile="C:\Python27\pythonw.exe" "%1" %*

C:\Users\***>assoc | findstr -i python
.py=Python.File
.pyc=Python.CompiledFile
.pyo=Python.CompiledFile
.pyw=Python.NoConFile

I've written a Basic Argument-Parsing Python Script that will parse a command line argument and print it back as a greeting. If the argument isn't present, one will be asked to enter it as a raw input. The results of explicitly calling Python first and not doing so are printed below:

C:\Users\***\Desktop>python input.py --greeting="john"
john
The greeting is:  john

C:\Users\***\Desktop>input.py --greeting="john"
None
Give me the greeting. johnrom
The greeting is:  johnrom
johnrom
  • 522
  • 2
  • 11
  • If limejs communicates with the script via pipes; [test whether `a.py | b.py` works on your OS](http://stackoverflow.com/q/466801/4279). If it doesn't; try to modify the registry as described in the link. – jfs Aug 31 '12 at 23:10
  • @J.F.Sebastian Pipes works on my OS, and LimeJS isn't using Pipes, it is calling the file directly from the command line as shown in the last code segment of the original post. – johnrom Sep 01 '12 at 18:10
  • Have you read the link? Do you understand the difference between `a.py | b.py` and `C:\Python27\python.exe a.py | C:\Python27\python.exe b.py`? What is "the original post"? I see no link in your question. – jfs Sep 01 '12 at 18:49
  • @J.F.Sebastian I edited the original question to show that there is no piping happening, replaced the proprietary applications with a program that I wrote, and showed an example of calling it directly from the command line. I hope this clarifies things! – johnrom Sep 01 '12 at 19:21
  • yes, [limejs doesn't use pipes for the script](https://github.com/digitalfruit/limejs/blob/00d38a98856340aba3798ece026f1400f25c401d/bin/lime.py#L147) (though it does use pipes (incorrectly) to call `git`). If all else fails; edit `update()` function and prepend `sys.executable or "python"` to the command – jfs Sep 01 '12 at 19:59

2 Answers2

0

I couldn't find the answer the first few times I searched, but I finally came across it in another stackoverflow post.

From the post:

I think I solved this. For some reason there is a SECOND place in the registry (besides that shown by the file associations stored in HKEY_CLASSES_ROOT\Python.File\shell\open\command):

[HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command] @="\"C:\Python25\python.exe\" \"%1\" %*"

This seems to be the controlling setting on my system. The registry setting above adds the "%*" to pass all arguments to python.exe (it was missing in my registry for some reason).

Adding '%*' to the end of this line worked for me, though it seems it didn't work for everyone.

Community
  • 1
  • 1
johnrom
  • 522
  • 2
  • 11
0

There is yet another registry key that you need to correct. As per this post you need to edit the

HKEY_CLASSES_ROOT\py_auto_file\shell\open\command

to be "C:\PythonPath\python.exe" "%1" %*

Community
  • 1
  • 1
David Hoffman
  • 2,205
  • 1
  • 16
  • 30