Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When running Python script at the command line I get this error

Windows cannot access the specified device, path, or file. You man not have the appropriate permissions to access the item.

How can I check what path does the system try to access? No entries are created in any of system logs (Application, Security, Setup, System). All solutions which I found on the web mention changing file's properties. The problem is in this case I don't know what file the system tries to use to handle Python script. How can I find this information? I guess a tool which monitors all files the system tries to open might help here.

Details

When I try to run Python script with .py extenstion at the command line by just giving script's name (like sample.py) I get the above error. I guess the problem is due to bad file association but... running reg query HKCR\.py /ve gives (Default) REG_SZ Python.File and reg query HKCR\Python.File\shell\open\command /ve gives (Default) REG_SZ c:\python\2.7\python.exe "%1" %* and the file c:\python\2.7\python.exe exists and I can run it from command line without problem. This makes me think that system tries to open Python script using some other path in the registry. The problem is I have no idea what's this path.

Windows Vista 64bit, running 64bit cmd.exe, 64bit Python.

EDIT

Process Monitor is very helpful but I still can't find the exact root causing problem. Trying to launch Python script generates 866 entries:

BUFFER TOO SMALL                 1
END OF FILE                      1
FILE LOCKED WITH ONLY READERS   12
NAME NOT FOUND                 301
NO MORE ENTRIES                  4
REPARSE                          5
SUCCESS                        542

There's no NO SUCH FILE result. I think it's because system doesn't even try to launch the executable to open Python file with due to not being able to find suitable registry entry defining handler for .py files. There are 178 entires of type RegQueryKey and 141 entries of type RegQueryValue but I have hard time trying to draw any conclusion reading them.

share|improve this question
    
"NAME NOT FOUND" == "NO SUCH FILE" –  Harry Johnston Apr 23 '12 at 5:14
    
If process monitor is showing entries for python.exe, then Python is definitely being launched. –  Harry Johnston Apr 23 '12 at 5:15

1 Answer 1

A quick Process Monitor Primer

  1. Open Process Monitor.
  2. Run your application and wait for the error to happen.
  3. Create a filter for your application, by right-clicking any of the entries that show the Process Name of your application and clicking Include 'yourapp.exe'.
    enter image description here
  4. Now see what kinds of return values, you've gotten. Open the Tools menu and click Count Occurrences.
    enter image description here
  5. In the Column field, select Result and hit Count.
    enter image description here
  6. Now look for an error that could correlate to your problem.
    We have 2 NO SUCH FILE errors, that sounds interesting. Let's double-click on it!
  7. And there we go...
    enter image description here
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.