0

If I execute my script by:

C:\Windows\System32>python C:\Code\Test.py XXX

It takes the argument but if I execute script by:

Test.py XXX

error occurs: IndexError...

So arguments do not pass to script. I have set the associations in Windows to open .py files with Python2.6. Running python programs from the command files runs well. However, if I type:

C:\Windows\System32>assoc .py
File association not found for file .py

Similarly:

C:\Windows\System32>ftype Python.File                                   
File type 'Python.File' not found or no open command associated with it.

PATH environment has been set properly: it has C:\Python26;as well as C:\Python26\Scripts. I have made sure that PATHTEXT has .PY in it. I can run my scripts, including iPython, easy_install, etc. without problems.

I have read about similar problems here in stackoverflow. A solution that has been suggested is to go to RegEdit, and look for all the occurrences of Python26 and make sure that the value data field has "C:\Python26\python.exe" "%1" %* instead of "C:\Python26\python.exe" "%1" when appropriate.

I am almost sure that I have done all of that, and I am still having the problem. I don’t know what else to do, and I am still learning a lot of these things as I go along, so I am not an expert and don't know what commands to type to test.

I am running Windows 7 on an iMac (Mac OS X Version 10.7.3) using Parallel, with 16GB of RAM. The reason I am using Windows on a iMac is because I am new to Mac, and I still don’t feel comfortable with all the Mac commands; however, I am starting to suspect that the problem is not with Python or Windows 7, but Parallel.

Thank you very much for your help

2
  • I don't see any specific question. Can you reword? What isn't exactly working? what error do you get? do you only want to associate .py to python.exe? May 10, 2012 at 13:17
  • Thank you. I reworded the question. Basically, arguments are not passed to the script. From the command prompt, it looks like there is no association to .py files, but in PATH and PATHTEXT, I can see that there is association.
    – sgjc65
    May 10, 2012 at 13:43

1 Answer 1

2
>assoc .py
.py=Python.File

>ftype Python.File
Python.File="C:\Python27\python.exe" "%1" %*

This is how it was setup in my box by the python installer.

So basically, just run

>assoc .py=Python.File
>ftype Python.File="C:\Python26\python.exe" "%1" %*

in a elevated console, restart windows just in case, and try again.

5
  • Thank you. I don't see any of that when I run assoc or ftype. Thats my problem: there is not recognition of the association within shell, so no arguments can be passed, and who knows what else.
    – sgjc65
    May 10, 2012 at 14:21
  • 1
    just run assoc .py=Python.File and ftype Python.File="C:\Python26\python.exe" "%1" %* in a elevated console, restart windows just in case, and try again. Is there any reason why you running 2.6 instead of 2.7? May 10, 2012 at 14:25
  • I apologize about my ignorance, but what is an elevated console? I'll try your suggestion after I learn about it. I am using Python26 because some libraries I am using or plan to use only work with 2.6. However, I am not running the latest version (2.6.8) because the official binaries I could find were the 2008 version (2.6.6), and I don't know how to install the 2.6.8 (2012) from source. If I can't get the 2.6.6 to work, I guess I'll have to unistall it and move to 2.7 and find a workaround. Thanks!
    – sgjc65
    May 10, 2012 at 14:36
  • 1
    an elevated console in w7 is a console with administrive rights. go to the "Start" button, type "cmd" in the search box, and hit ctrl+shift+enter, and the UAC will pop up a window asking you if you want to run the command (a windows console) in elevated mode. May 10, 2012 at 15:00
  • Thank you KurzedMetal! The command in the second comment, done from an elevated console solved my problem. Cheers
    – sgjc65
    May 10, 2012 at 22:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .