简体   繁体   中英

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?

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.

I'm new to Python too, but as far as I understand, the main () module cannot be re-loaded. I believe this is not a real error or something to be concerned about.

转到首选项 - > PyDev - >交互式控制台,取消选中或清除标题为“将控制台连接到调试会话?”的复选框。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM