"Could not import settings" error
Brought to you by:
fabioz
I just installed the latest released production version of PyDev (2.0), and now when launching my project (tiger) in debug I consistently get this message and it won't start. Yesterday with the previous version of PyDev it worked fine. Any ideas?
pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)
pydev debugger: starting
Error: Could not import settings 'tiger.settings' (Is it on sys.path? Does it have syntax errors?): Could not import settings 'tiger.settings' (Is it on sys.path? Does it have syntax errors?): No module named settings
Is your project configured as django? It seems that it's expecting tiger.settings to be your django settings module -- if the settings module is in a different location, please create a string substitution variable named 'DJANGO_SETTINGS_MODULE' in your project (right click project > properties > PyDev PYTHONPATH > String substitution variables) and point that variable to your module name (i.e.: tiger.my_settings).
If your project is not a Django project, this shouldn't happen (note that you can remove the django project configuration by right clicking the project > django > remove django project config).
The lack of the DJANGO_SETTINGS_MODULE was indeed the issue. I could have sworn that was there previously though. If not, I wonder how it worked in debug yesterday? Anyway, thanks so much. Great tool!
This variable wasn't properly passed when launching pydev (which could lead to other errors), and now if not specified a 'default' is used -- maybe it should always ask instead of trying to use a default... will think a bit about it :)
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "(deprecated) Please use https://www.brainwy.com/tracker/PyDev/"
Ok, this issue has kept me occuppied for quite some time now. I found the reason in the source code I downloaded from Github. Eventually I found this issue here at sf.
I don't know if it can be classified as a bug, but it is quite annoying. I was attempting to set the DJANGO_SETTINGS_MODULE in the Environment tab of a 'run configuration'. But setting it there won't work because it gets overridden by `PythonRunnerConfig` . You _have_ to set it in your *project's* properties. This is not clearly stated in the docs.
Note I'm in this case only using django's db api from my own scripts (not running manage.py).
Cheers.
Marko
Last edit: Anonymous 2013-11-21