Menu

Unresolved import

2010-12-20
2013-03-15
  • Michael Bartz

    Michael Bartz - 2010-12-20

    I continue to get an "unresolved import error" from PyDev even though the module imports.

    import atom
    print atom.__file__
    

    gives me the error even though I have added the site-package to both the PYTHONPATH and the project preferences. 

    I am running the latest version of both Eclipse and PyDev

     
  • ahunor

    ahunor - 2010-12-24

    Any ideas how to solve this ?

    Installing django from package, addig dist-packages or site-packages, or just simply downloading it separately and adding the folder it resides in to the PYTHONPATH doesn't help.
    I suppose it's a regression…a really nasty one.
    Pointers on how to fix it ?

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2010-12-31

    Can you paste the pythonpath you're using and the place where the package is installed (to get the pythonpath, make a run and do import sys; print '\n'.join(sys.path).

    Cheers,

    Fabio

     
  • Eugen

    Eugen - 2011-01-15

    Hello Guys,
    I have slightly different one:

    Importing test modules ... Traceback (most recent call last):
      File "/home/eugen/Work/Helios-Python/eclipse/plugins/org.python.pydev.debug_1.6.4.2011010200/pysrc/pydev_runfiles.py", line 263, in __get_module_from_str
        mod = __import__(modname)
      File "/home/eugen/Work/Helios-Python/workspace/Dionysus/test/main/test_qaf.py", line 9, in <module>
        from Dionysus.DialogueManager.QAF import QafTemplate, QafInstance
      File "/home/eugen/Work/Helios-Python/workspace/Dionysus/src/Dionysus/DialogueManager/QAF.py", line 11, in <module>
        from Dionysus.DialogueManager.Context import Context
      File "/home/eugen/Work/Helios-Python/workspace/Dionysus/src/Dionysus/DialogueManager/Context.py", line 7, in <module>
        from Dionysus.DialogueManager.log_utils import log_debug
      File "/home/eugen/Work/Helios-Python/workspace/Dionysus/src/Dionysus/DialogueManager/log_utils.py", line 11, in <module>
        from Dionysus.DialogueManager import io_utils
      File "/home/eugen/Work/Helios-Python/workspace/Dionysus/src/Dionysus/DialogueManager/io_utils.py", line 8, in <module>
        from Dionysus.DialogueManager.QAF import QafTemplate
    ImportError: cannot import name QafTemplate
    ERROR: Module: test_qaf could not be imported (file: /home/eugen/Work/Helios-Python/workspace/Dionysus/test/main/test_qaf.py).
    

    What seems to be the problem for me is 'file: /' there is a space and I think it is causing the error.
    I started to have this error since I updated PyDev.
    Any suggestions?

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-01-16

    I just took a look at the print and the space there is expected (so, that's not it).

    Can you double check if you really have a QafTemplate  in the Dionysus.DialogueManager.QAF module?

    Another thing, if you make a regular run of that module (/home/eugen/Work/Helios-Python/workspace/Dionysus/test/main/test_qaf.py) does it work? (note that you need to have a "unittest.main()" for it to properly run your tests in that case).

    If it doesn't, then it's a problem in your code (not really in pydev), now, if it does, can you paste the pythonpath you're using?  (to get the pythonpath, make a run and do import sys; print '\n'.join(sys.path).

    Cheers,

    Fabio

     
  • Eugen

    Eugen - 2011-01-16

    After 2 days of head-slamming on the table I have discovered an import loop in my code.

    I have come to conclusion that Python does not handle cyclic imports.

    The error "ImportError: cannot import name" is really annoying since it is not clear where to look for the problem, or at least there should be somewhere a list of TODO's when that error occur, to find the reason for the exception.

    Thank you fabioz for your nicely crafted response.

    Sincerely Eugen

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.