I'm deploying a (proprietary) Django application (with bad support ;-)). The only thing I need to do is setup a new Django project and implement the app's urls. So my url config is as follows:
1 from django.conf.urls.defaults import patterns, include, url
2
3 urlpatterns = patterns('',
4 url(r'^', include('ap01.urls')),
5 )
The application in question is also added to my INSTALLED_APPS setting.
I can validate (./manage.py validate) and all is good. When running the app I get the following import error:
ImportError at /
No module named ap01.urls
The module is present in the Python Path reported by Django and when manually importing the urls module everything works, ie:
开发者_高级运维./manage.py shell
__import__('ap01.urls')
I compared setups with the QA and dev servers and everything seems be in place correctly. The only thing that differs is the Python version (2.6 on QA and dev; 2.7 on this new machine).
I would debug this like this:
You need to know where the ImportError gets raised. Then add something like this:
import sys
raise Exception(sys.path)
- Is the directory above "ap01" in sys.path?
- Does the directory ap01 contain a
__init__.py
file? - What user-id has you python interpreter (the one which raises the import exception)? Try:
import os, sys; assert False, (os.getuid(), sys.path)
- Maybe this user-id has not enough permission to read the file? Get this user with "su" (if you use a unix like OS) and then try to read it:
less ...../ap01/...py
精彩评论