ImportError: cannot import name <module> only when running file from atom

ImportError: cannot import name <module> only when running file from atom

给定目录 /khwarizmi 上的两个文件,例如 /khwarizmi/linear.py/khwarizmi/exceptions.py,当通过 OS 命令行(Ubuntu 18.04 ).然而,当我 运行 来自 Atom 的脚本(无论是来自 Hydrogenpython-run 还是 script 包时,我得到

  Traceback (most recent call last):
  File "/home/santiago/Documentos/ScriptLab/Repos/khwarizmi/khwarizmi/linear.py", line 1, in <module>
    from exceptions import (InvalidFormError, LinearSolutionError,
ImportError: cannot import name InvalidFormError
[Finished in 0.074s]

导入是这样写的:

 from exceptions import (InvalidFormError, LinearSolutionError,
                        RedundantConversionError)

# The following are other imports that, provided
# they were executed, raise the same error.

import equations
from equations import operators
from lib.misc import cond_assign, num

我尝试调整似乎相关的包设置;例如,将 默认 CWD 设置从 第一个项目目录 更改为 脚本的项目目录 脚本的目录,但这并没有改变任何东西。

我的问题是,为什么当 运行从 Atom 包中运行脚本时这不起作用,但它从命令行运行?

(如果您想查看存储库的结构或完整代码,请参阅:https://github.com/lpereyrasantiago/khwarizmi

exceptions 是一个 python 标准模块。如果您为私有模块使用相同的名称,这可能会混淆。