ImportError: cannot import name ModuleA

好久不见. 提交于 2019-12-12 17:58:17

问题


I have the following stacktrace when I try to import ModuleA:

    Traceback (most recent call last):                                                          
  File "menu.py", line 9, in <module>                                                       
    from tmserver import Module1                                                          
  File "~/tmserver/Module1.py", line 10, in <module>                                                                           
    from tmserver.PackageA import ModuleA                                             
  File "~/tmserver/Package1/ModuleA.py", line 8, in <module>                                                               
    from tmserver.Package2 import Module2                                               
  File "~/tmserver/Package2/Module2.py", line 15, in <module>                                                                
    from tmserver.Package3 import Module3                                                      
  File "~/tmserver/Package3/Module3.py", line 5, in <module>                                                                        
    from tmserver.PackageA import ModuleA                                            
ImportError: cannot import name ModuleA

Is this because it's importing ModuleA again/recursively?


回答1:


That would seem like the logical conclusion; perhaps if you posted samples of the code you were running you'd be able to get a better reply?



来源:https://stackoverflow.com/questions/4707111/importerror-cannot-import-name-modulea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!