PyDev run configuration: ImportError: No module named

5.7k views Asked by At

I am using LiClipse on OSX and trying to run django application using the Eclipse run configuration (this manages the virtualenv?). The app is not of my creation but works in production so I assume it is my environment that needs corrected. The app is structured as:

PyDev Project Folder
--manage.py
--requirements.txt
--django-app-folder
-----config-folder
--------__ini__.py
--------settings.py
--------evniroments.py
--------urls.py
--------wsgi.py
-----app-folder
--------__ini__.py
--------lots of other stuff

When I try to run the application it fails to import a module: enter image description here

This appears to be fairly common, at least there a several other questions that are comparable and many dated ones such as: Eclipse + PyDev ImportError and ImportError: cannot import name... but they do not answer the question of how to configure the Eclipse run correctly for PyDev?

I have followed the docs at PyDev and the guidance in the referenced SO links such as removing the interpreter settings from PyDev and then adding it back and "Check if interpreters are synchronized with environment".

Here is the PYTHONPATH for the run config I am using: enter image description here

And the interpreter settings under PyDev preferences - I have tried both the egg and the folder as well as each on their own: enter image description here

2

There are 2 answers

0
Fabio Zadrozny On

There something strange in your PYTHONPATH: you have a django_filters_xxx.egg entry and a django_filters_xxx.egg/filters entry, which seems odd... is the .egg a folder or a zip in your case?

Does it work in the command line? If it works in the command line, you can try adding:

import sys
print('\n'.join(sorted(sys.path)))

on the command line and comparing with the one in PyDev to check if there's something wrong there.

Another common issue is that sometimes you are shadowing the import with a module with the same name in your project.

1
jean pierre huart On

I had a similar problem with eclipse on linux. I solved it defining the 'Django settings module' in the 'PyDev - Django' chapter of the project properties.

In your case it should be 'django-app-folder.config-folder.settings'.

Hope it helps.