I have a rather complex mostly-python application (that I inherited) and when I run it in windows from a file type association (double click on a data file in explorer), I get a crash in the middle of the python multiprocessing:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named MainModule
If I run the application from the windows command line, it runs successfully:
python MainModule.py {full file pathname}
The failure occurs when the "start" method of a process object is invoked.
Because this is deeply buried in python itself, I'm having trouble figuring out what could be causing this. I've tried setting the working directory to the main module directory before the process object start or, indeed, process object creation, but without any improvement. I've also looked at the value of the data passed to "prepare", but apart from the original directory, there doesn't seem to be any difference.
Can anyone suggest where and/or how I ought to look into this?
Edit:
I am associating a data file with the python application, which processes it. If I issue the command on the command line in the same directory as the python application main module, it works. If I try to issue the same command via a file association, it fails. I can associate a bat file that changes to the application directory, issues a plain "cd" command, printing the directory (no idea why this is necessary, but it seems to be) and then starts the application with the data file as a parameter - just as the association does - and it works. I think this has something to do with the python module search path, but no idea what...
Edit 2:
Wow, that was embarrassing. The problem was in the association (sort of). The invoked script was invoked with incorrect capitalization... The script is executing successfully but when the process tries to fork, multiprocessing looks for the incorrectly capitalized filename and ... doesn't find it! So windows doesn't care about capitalization and Python on windows sort of follows suit: it doesn't for script execution, but does for process forking...