Search code examples
importpython-3.xpydeveclipse-juno

Unresolved import errors yet successful import still occurs


I am working on a project in Eclipse Juno. I wrote a class called Character in a package named chargen.py. There's a red X next to from chargen import Character:

Unresolved import: Character
Character Found at: Avarice_v0.PlayAvarice_v0

from chargen import Character

Yet the import works. The entire code at the moment is simply this:

from chargen import Character

def main():
    PLAYER = Character("")
    print(PLAYER)

if __name__ == '__main__':
    main()

This code results in the printing of the __str__ proving the Character("") ran. Also, it generates no errors when running. Why does Eclipse label this Unresolved import: Character?

Red X In Eclipse Example


Solution

  • I figured out how to get rid of the error. I moved everything one directory up. Settings for the project showed the PYTHONPATH included the main directory, but not the nested one. By moving it all up and deleting the now empty original folder, I have no unresolved import errors. This helped me to understand more about the PYTHONPATH choices offered at the initial setup of the project in PyDev.