【发布时间】:2016-06-04 00:13:27
【问题描述】:
我正在尝试导入一个模块,但我不断收到 ImportError。
在 PortfolioStatus.py 文件中,我有以下代码从 share_data.py 模块导入 share_data 类
from Shares.share_data import share_data
我收到以下错误:
File "/home/lucasamos/FYP/Shares/Communication/PortfolioStatus.py", line 3, in <module>
from Shares.share_data import share_data
ImportError: No module named Shares.share_data
为了让事情更混乱,这在我的本地机器上运行良好,但我在 PythonAnywhere 上托管,这就是我得到错误的地方
我的文件层次如下图所示
提前致谢!
【问题讨论】:
-
运行配置中的工作目录是什么?这将被添加到
sys.path。如果您将其设为项目目录(将其留空)Shares应该是可导入的。
标签: python python-2.7 python-import pythonanywhere