Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pydev debugger: Unable to find module to reload

I wrote a python module in Eclipse and called it main.py

The code:

if __name__ == "__main__":  
    inFile = open ("input.txt", 'r')
    inputData = inFile.readlines()

    print 'all done :)'

Well, it runs, but every time I save the project, I get this error in the console:

pydev debugger: Unable to find module to reload: "main".

Any idea what it means?

like image 359
Cheshie Avatar asked Nov 17 '14 18:11

Cheshie


1 Answers

pydev debugger: Unable to find module to reload:

There message doesn't indicate a problem with your program. It means that you saved a source file in Eclipse and pydev was trying to reload the new code. The message is generated by pysrc/pydevd.py in the processNetCommand() method when a CMD_RELOAD_CODE command is received (from Elcipse?). That 'reload' command is looking for your module (named 'main' in your question) in the sys.modules list. This list maps the module name to the module object (which includes the name of the file to reload the module from)

Because 'main' was not found in the sys.modules dictionary, it issues that message. If it had found 'main' in sys.modules it would have passed sys.modules['main'], which should be a , to xreload() from from pydevd_reload module. I think this has something to do with the way that pydev loads your module in the Eclipse/python debug environment.

The result is that the updates to your python code are not reflected in the debugger. And that you must terminate the debug session and start it again from the top -- which is sort of normal operation for debugging when you change the source code.

I've played with appending my module to sys.modules so that it can find the module to reload. It's neat that you can do that, but generally not of much practical use.

like image 124
Ribo Avatar answered Nov 15 '22 04:11

Ribo