3
我有蟒蛇模塊結構如下:如何從子模塊導入python腳本?
/foo.py
/module
/module/__init__.py
/module/submodule/__init__.py
/module/submodule/bar.py
在foo.py我有以下代碼:
from module.submodule.bar import *
但作爲結果,我發現了以下錯誤:
'.../module/bar.py': [Errno 2] No such file or directory
爲什麼python試圖找到/module/bar.py文件,但不是模塊/子模塊/欄,如我在導入中所述?
適合我。你在'__init __。py'文件中有一些奇怪的東西嗎? – geoffspear
這不是從導入中獲得的錯誤。好像你有一些'bar.py'或'__init __。py'文件中的'open(something)'的代碼。 –
是的......這是PyCharm重構後的一個非常奇怪的行爲。運行配置的休閒解決了這個問題。謝謝大家,你給了我一個想法,試着從控制檯運行它,它的工作。 – bigdatarefiner