views:

38

answers:

2

I recently moved a django app from c:\Users\user\django-projects\foo\foobar to c:\Python25\Lib\site-packages\foo\foobar (which is on the python path). I started a new app in the django-projects directory, and added foo.foobar to the INSTALLED_APPS setting. When I try to run the dev server (manage.py runserver) for my new app, I get the error ImportError: No module named foobar.

Looking through the traceback, it's looking in the c:\Users\user\django-projects\foo\..\foo\foobar for the foobar app. I checked my PATH and PYTHONPATH environment variables, and neither point to c:\Users\user\django-projects\foo and It doesn't show up in sys.path when I run the python interpreter.

I'm guessing I somehow added c:\Users\user\django-projects\foo to django's path sometime along the development of foo but I don't remember how I did it.

So, with all that lead up, my question is "how do I make manage.py look in c:\Python25\Lib\site-packages instead of c:\Users\user\django-projects\foo?"

Thanks,

  • Lexo
+1  A: 

manage.py imports settings.py from the current directory and pass settings as parameter to execute_manager. You probably defined project root in settings.py.

laurent-rpnet
@laurent Thanks. I checked my `settings.py` and there's no trace of `django-projects` in it at all. I'm beginning to think I'm going crazy. I'll do some more testing and see what I can come up with.
Lexo
did you try to use the managed shell (`python manage.py shell`) to see what's in sys.path. `..../foo` should be the first one there. Just to check... as if it is not there, I don't know how to correct! but if it's there, I think your problem is not a path problem. Maybe permissions? Is `__init__.py` empty?
laurent-rpnet
I fixed the problem (see below), but you did answer my original question, so I marked your question as the correct one. Thanks for your help!
Lexo
Happy to see it's solved! :) and thanks for the accept even with a very indirect help.
laurent-rpnet
+1  A: 

I fixed it, although I don't know which solution worked. First, I deleted the .pyc files from my project, then I reindexed my Windows search (I'm guessing this did it). This changed the error message to the correct directory. After which, i realized I had

from baz import settings

in my foobar/baz/models.py file, which was causing the problem all along. I changed this to

import stettings

which fixed the problem. Thanks to laurent for all your help :-)

Lexo
yes I think the .pyc removal did it
laurent-rpnet