I started using django-nose because I wanted to to run only my apps' tests via python manage.py test, but I'm running into this ImportError: no modules named urls.
This project is using Django 1.4.
The folder structure is like so:
project
├── manage.py
├── project
├── apps
│ ├── app1
| ├── __init__.py
│ ├── tests.py
│ └── app2
│ └── app3
├── settings.py
├── urls.py
└── views.py
However, when I run python manage.py test, I get an ImportError: no module named urls:
Traceback (most recent call last):
File "/Users/huey/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 89, in get_response
response = middleware_method(request)
File "/Users/huey/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/middleware/locale.py", line 21, in process_request
check_path = self.is_language_prefix_patterns_used()
File "/Users/huey/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/middleware/locale.py", line 54, in is_language_prefix_patterns_used
for url_pattern in get_resolver(None).url_patterns:
File "/Users/huey/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 328, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/huey/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/core/urlresolvers.py", line 323, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/Users/huey/.virtualenvs/myvirtualenv/lib/python2.7/site-packages/django/utils/importlib.py", line 38, in import_module
__import__(name)
ImportError: No module named urls
Things I have tried that didn't work:
- Per the Django-nose docs, tried killing init.py from the outer project folder. This didn't change anything.
- Tried setting up everything in a fresh virtualenvironment.
- I went into importlib.py and added printed out the name, package, and sys.path:
name: project.urls package: None sys.path: ‘/Users/huey/code’ ‘/Users/huey/code/project’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python27.zip’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7/plat-darwin’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7/plat-mac’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7/plat-mac/lib-scriptpackages’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7/lib-tk’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7/lib-old’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7/lib-dynload’ ‘/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7’ ‘/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin’ ‘/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk' ‘/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac’ ‘/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages’ ‘/Users/huey/.virtualenvs/projectfresh/lib/python2.7/site-packages’ ‘/Users/huey/code/project/project/apps’ ‘/Users/huey/code/project/project/common’ ‘/Users/huey/code/project/project/lib’
ROOT_URLCONF is 'project.urls'
I'm not sure where to go from here. Any ideas?
I figured it out. Even though I removed init.py, I forgot to remove its corresponding .pyc file.