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 ques开发者_开发问答tion is "how do I make manage.py look in c:\Python25\Lib\site-packages instead of c:\Users\user\django-projects\foo?"
Thanks,
- Lexo
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.
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 settings
which fixed the problem. Thanks to laurent for all your help :-)
加载中,请稍侯......
精彩评论