Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django app in Eclipse won't run after upgrade to django 1.4

After upgrading to Django 1.4, I now get the following error message:

raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named py

I read that it might have something to do with pydev 2.4 eg: here, so I upgraded pydev to the latest version, 2.5. I am using eclipse indigo.

I started to have a look at the run cnofiguration, and noticed that the django 1.3 egg was still being referenced. So I went to windows/preferences/pydev/interpreter-python, and the 1.3 egg was being referenced in the system PYTHON path.

To try and correct this, I removed the existing python interpreter, and re-added a new one. My python is run from venv, so I added this. An error comes up:

Error message

I don't think this is related, but I can see that /venv/lib has appears in the System PYTHONPATH list, whereas in Windows the folder is called /venv/Lib, so I added this as well. Still the new django egg hasn't been include, so I manually added this under the 'Libraries' window.

However, I'm still receiving the error message.

The app runs fine from the command line.

like image 487
Trent Avatar asked Apr 21 '12 11:04

Trent


2 Answers

Figured this out after a few hours of trying different things.

I created a new Django project using the pydev 2.5 just to see what would happen, and I noticed that the 'django settings module' entry (see below) was appname.settings. Previously I had put 'settings.py'. I removed the entry entirely, which cleared up the first problem.

enter image description here

After this I was getting a 'module appname not found' error, so I tried putting an empty __init__.py file in the root of my app, which seemed to work.

like image 74
Trent Avatar answered Oct 04 '22 15:10

Trent


In a virtualenv, this is usually the case where you forgot to add the /Lib from the base python install during the install process (so, when searching in the PYTHONPATH it's not finding things such as 'threading.py' or 'traceback.py', etc.

like image 37
Fabio Zadrozny Avatar answered Oct 04 '22 16:10

Fabio Zadrozny