简体   繁体   中英

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

Given two files on the directory /khwarizmi such as /khwarizmi/linear.py and /khwarizmi/exceptions.py , importing functions and classes from one another works without problem when running the scripts through the OS command line (Ubuntu 18.04). Yet, when I run the scripts from Atom (whether it is from the Hydrogen , the python-run or the script packages, I get

  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]

This is how the imports are written:

 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

I tried tweaking the packages settings that would seem relevant; for example, changing the Default CWD setting from first project directory to project directory of the script or directory of the script , but this didn't change anything.

My question is, why doesn't this work when running the scripts from Atom packages, but it does from the command line?

(If you want to see how the repository is structured, or the full code, see: https://github.com/lpereyrasantiago/khwarizmi )

exceptions is a python standard module. If you use same name for your private module, this may mix-up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM