python:fromx导入isn';我不能在目录中工作

python:fromx导入isn';我不能在目录中工作,python,Python,我的文件是这样的 -root/ -main.py -nyaizhel_includes/ -includemain.py -commands/ -astolfo.py -naruto.py ... 从main.py导入includemain.py from nyaizhel_includes import includemain 它可以工作,includemain.py被导入 从includemain.py导入命令 from commands import as

我的文件是这样的

-root/
 -main.py
 -nyaizhel_includes/
  -includemain.py
  -commands/
   -astolfo.py
   -naruto.py
   ...
从main.py导入includemain.py

from nyaizhel_includes import includemain
它可以工作,includemain.py被导入

从includemain.py导入命令

from commands import astolfo
from commands import narutobanner
from commands import rgirl
...
includemain.py被包括在内,但astolfo没有被包括在内,为什么?

控制台日志

heroku[main.1]: State changed from starting to up
2021-04-13T09:42:02.840988+00:00 app[main.1]: Traceback (most recent call last):
2021-04-13T09:42:02.841010+00:00 app[main.1]:   File "/app/main.py", line 42, in <module>
2021-04-13T09:42:02.841140+00:00 app[main.1]:     from nyaizhel_includes import includemain
2021-04-13T09:42:02.841141+00:00 app[main.1]:   File "/app/nyaizhel_includes/includemain.py", line 1, in <module>
2021-04-13T09:42:02.841258+00:00 app[main.1]:     from commands import astolfo
2021-04-13T09:42:02.841262+00:00 app[main.1]: ModuleNotFoundError: No module named 'commands'
2021-04-13T09:42:02.950174+00:00 heroku[main.1]: Process exited with status 1
2021-04-13T09:42:03.023470+00:00 heroku[main.1]: State changed from up to crashed
heroku[main.1]:状态从启动更改为启动 2021-04-13T09:42:02.840988+00:00应用程序[main.1]:回溯(最近一次通话): 2021-04-13T09:42:02.841010+00:00应用程序[main.1]:文件“/app/main.py”,第42行,在 2021-04-13T09:42:02.841140+00:00附录[main.1]:来自nyaizhelèu的包括进口includemain 2021-04-13T09:42:02.841141+00:00应用程序[main.1]:文件“/app/nyaizhel_includes/includemain.py”,第1行,在 2021-04-13T09:42:02.841258+00:00应用程序[main.1]:从命令导入astolfo 2021-04-13T09:42:02.841262+00:00应用程序[main.1]:ModuleNotFoundError:没有名为“commands”的模块 2021-04-13T09:42:02.950174+00:00 heroku[main.1]:进程退出,状态为1 2021-04-13T09:42:03.023470+00:00 heroku[main.1]:状态从高变为崩溃
您没有在示例中列出您的
\uuuu init\uuuuuuy.py
文件,因此请确保添加这些文件,以便将其识别为标准包(尽管您可能已经有了)

错误的来源可能是您试图进行相对导入,但指定了绝对导入:

如果使用
from.commands import astolfo
(注意表示相对导入的句点),应该可以解决问题。但是,建议按照标准使用绝对进口。在您的情况下,这将是nyaizhel_includes.commands导入astolfo,假设这里的根包是
nyaizhel_includes

有关更多信息,请参阅。

在nyaizhel_includes中添加init.py文件。请参阅,并提供详细信息。如果你说“像这样”,然后显示一个
naruto.py
,然后包含一个
narutobanner
模块,那是没有用的。