Reputation: 3075
I have two folders - modules and test - within my admin app. Each folder contains its own models. I'm trying to import between the two folders.
Importing from modules in test: from exam.admin.modules.models import Subject
It works fine, but Pydev Eclipse shows me an unresolved import error. Any reason?
Upvotes: 5
Views: 10482
Reputation: 11
You may try to configure Source Folders and check if this can solve the problem. Right click on the Project, click on Properties. Open the PyDev - PYTHONPATH tab. Check the Source Folders defined. These Source Folders are your "root" source folders. Probably there is no source folder for the directory of the not found classes.
Upvotes: 1
Reputation: 11760
As others have said, as long as your program runs then you can safely ignore PyDev/Eclipse's warning. PyDev seems to like relative imports within a project. You could leave off the project name from the import path, but there's a clearer way to show the hierarchy using dots. "Go up one level, into the modules directory, and import Subject from the models.py file."
from ..modules.models import Subject
More on Python importing standards (absolute versus relative recommendations) in PEP 328
Upvotes: 6
Reputation:
I would not worry about PyDev's import error if your app works. I am sure there are bugs in PyDev/Eclipse
Upvotes: 0