2

I'm trying to run a Python script from the command line in Windows 7, but the interpreter seems to ignore all commend line arguments. It does not do so when I run the command as

python C:\PathToScript\script.py arg1

or when I launch the terminal with Administrator permissions. It used to work normally until I had to reinstall Python (2.7.2), so I've probably managed to break some file association for standard users. The solutions in Python Command Line Arguments (Windows) do not work for me, as the registry entry is already set up with %*:

Key Name:          HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command
Class Name:        <NO CLASS>
Last Write Time:   3/04/2012 - 14:19
Value 0
  Name:            <NO NAME>
  Type:            REG_SZ
  Data:            "C:\Python27\python.exe" "%1"  %*

It's not a major problem, but I've gotten used to just shift+clicking in a directory and opening a terminal there, whereas I now have to run an elevated cmd prompt, type the Administrator account name and password and navigate to the right folder in order to run the script properly. Does anyone know where I can find this user specific file association or if there's another way to solve this?

Community
  • 1
  • 1
lackodan
  • 148
  • 10
  • Can you post a registry dump of `HKCR\Applications\python.exe`? Also, is this a system-wide install or user-local? Maybe a user-specific registry entry is shadowing the system-wide config. – Niklas B. Apr 03 '12 at 13:17
  • Sure, here is the registry dump: http://pastebin.com/f64UHjE7. It's a system-wide install (both installs have been system-wide). – lackodan Apr 03 '12 at 13:50
  • Are you on a 64-bit install? The registry is duplicated on these systems, there's one for 64-bit processes and one for WOW64 (32-bit). Explorer is 64-bit, maybe you edited the wrong entry. How did you start regedit? – Niklas B. Apr 03 '12 at 13:53
  • I started regedit with Start->Run->"regedit", which should show both 32-bit and 64-bit keys. When I start the 32-bit registry editor with Start->Run->"%systemroot%\syswow64\regedit" the value seems to be still right: http://pastebin.com/Ak2fbpUa. I don't know if it helps, but here is a registry dump from the 32-bit node in the 64-bit registry editor for Python: http://pastebin.com/Es2Eyxnw. – lackodan Apr 05 '12 at 08:23
  • Did you ever resolve this.. I have the same problem. – panofish Feb 27 '15 at 07:10
  • Unfortunately, I don't remember ever resolving this. I've since switched to a Windows 8 and to installing python through [Anaconda] (https://store.continuum.io/cshop/anaconda/). I highly recommend Anaconda; it's completely free and makes installing Python so much easier. I used to spend days installing, compiling and configuring Python + VTK, now it's a matter of minutes. Haven't had any major problems since. – lackodan May 05 '15 at 10:45

1 Answers1

0

I would presume that you are running the script from some kind of the shortcut, as console is not involved. Can it be that the shortcut did have parameters, while not it does not and you should only resupply those in the Program section of the properties for the shortcut.

Alexey Vassiliev
  • 2,349
  • 2
  • 17
  • 8