Forums

Import error no module named (my module)

This is puzzling me. I've spent a long time getting my settings.py recognised by wsgi (I finally learned what was needed for the path). Now settings.py seems to be ok but I get the following error (my module is called 'guests').

2016-11-10 17:01:13,644 :Error running WSGI application Traceback (most recent call last): File "/bin/user_wsgi_wrapper.py", line 154, in call app_iterator = self.app(environ, start_response) File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application raise e ImportError: No module named guests

This works on my local machine. 'guests' isn't referenced in wsgi.py so it must be reporting a problem as it reads through settings.py.

Any suggestions gratefully received.

We have a help page for debugging import errors

I've looked at that Glenn, but can't see that there is an issue with my file placements and references

Can I take a look at your code? We can see it from our side, but we always ask permission first.

Yes, thank you. I'm away from the laptop for a few weeks from Saturday, so no hurry!

OK, so in your WSGI file you've added /home/sidestrand/mariners_site/mariners/mariners to the system path and set your DJANGO_SETTINGS_MODULE to settings. That's OK in itself, because your settings file is indeed /home/sidestrand/mariners_site/mariners/mariners/settings.py.

But then in the settings, you have an INSTALLED_APPS called guests, along with various others. Because your system path is /home/sidestrand/mariners_site/mariners/mariners, it's looking for that in /home/sidestrand/mariners_site/mariners/mariners/guests -- but it's actually in /home/sidestrand/mariners_site/mariners/guests.

You should change the WSGI file so that you add /home/sidestrand/mariners_site/mariners/ to the system path, and set the DJANGO_SETTINGS_MODULE to mariners.settings

Thank you Giles. That worked a treat. I must get my head round this referencing. It works as initially set up on my laptop. Anyway, brilliant service!

Excellent, glad to help!