python ImportError:没有模块名称engines.extras.download_datos_desambiguar

时间:2015-03-23 14:48:07

标签: python file import lucene importerror

我有以下层次结构

  • SRC(文件夹)

    • 引擎(文件夹)

      • ProcesosContinuos.py

      • 额外(文件夹)

        • download_datos_disambiguar(文件夹)
          • news_Lucene.py

ProcesosContinuous.py我正在导入news_Lucene.py,就像这样

from engines.extras.download_datos_desambiguar import news_Lucene

但是在运行它时,它给了我一个错误:

ImportError: No module name engines.extras.download_datos_desambiguar 

我尝试了很多关于导入行的调整但没有任何帮助我。我试过查看与此相关的许多SO帖子,但似乎没有什么是我正在寻找的。

我还尝试使用以下代码

在文件夹engines中创建一个shell脚本
python ~/code/4dlife_repo/4dbatch/src/engines/extras/download_datos_desambiguar/news_Lucene.py

这很好用。因此news_Lucene.py代码或其相关路径没有问题。那么我在这里做错了什么?

2 个答案:

答案 0 :(得分:1)

原来我只需要在每个文件夹中添加__init__.py,以便将其用作Python包。

答案 1 :(得分:-2)

通常,我会打印出sys.path以查看根文件夹是否存在。在你的情况下,我认为~/code/4dlife_repo/4dbatch/src应该在sys.path。

相关问题