2
votes

I'm getting the following error:

ImportError at /
No module named midi_app
Request Method: GET
Request URL:    http://127.0.0.1:8000/
Django Version: 1.4.1
Exception Type: ImportError
Exception Value:    No module named midi_app
Exception Location: /Users/home/virtualenv/venv/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable:  /Users/home/virtualenv/venv/bin/python

I have added my app "midi_app" to the INSTALLED_APPS section in settings.py. I'm not sure why I'm seeing this error. Could the virtualenv have anything to do with it?

Thanks.

UPDATE: I've added as many directories as I can think of and I'm still seeing this error. Please see my path below. Please assist, I'm getting really frustrated.

'/Users/home/virtualenv/venv/lib/python27.zip',

'/Users/home/virtualenv/venv/lib/python2.7',

'/Users/home/virtualenv/venv/lib/python2.7/plat-darwin',

'/Users/home/virtualenv/venv/lib/python2.7/plat-mac',

'/Users/home/virtualenv/venv/lib/python2.7/plat-mac/lib-scriptpackages',

'/Users/home/virtualenv/venv/lib/python2.7/lib-tk',

'/Users/home/virtualenv/venv/lib/python2.7/lib-old',

'/Users/home/virtualenv/venv/lib/python2.7/lib-dynload',

'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',

'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',

'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',

'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',

'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',

'/Users/home/virtualenv/venv/lib/python2.7/site-packages',

'/Users/home/Desktop/Web Development/Django-1.4',

'/Users/home/virtualenv/venv',

'/Users/home/Desktop/Web Development/Aptana Studio 3.0',

'/Users/home/virtualenv/venv/bin',

'/Users/home/Desktop/Web Development',

'/Users/home/virtualenv',

'/Users/home/virtualenv/venv/lib/python2.7/site-packages/PIL',

'/Users/home/virtualenv/venv/lib/python27.zip',

'/Users/home/virtualenv/venv/lib/python2.7/plat-darwin',

'/Users/home/virtualenv/venv/lib/python2.7/plat-mac',

'/Users/home/virtualenv/venv/lib/python2.7/plat-mac/lib-scriptpackages',

'/Users/home/virtualenv/venv/lib/python2.7/lib-tk',

'/Users/home/virtualenv/venv/lib/python2.7/lib-old'

3
show your project's directory structure. you might need to add your project name (i.e. myproject.midi_app) if your app is not under the project level.dannyroa

3 Answers

1
votes

Turns out my url was wrong.

I was specifying it as

url(r'^$', 'musicproject.midi_app.views.index'),

instead of

 url(r'^$', 'midi_app.views.index'),

Thanks for all your help.

0
votes

No the virtualenv has nothing to do with this error. Its an ImportError that means that it is not able to find your app in the location you specified, recheck the path of the app and the path you provided and also the name.

0
votes

One other thing to note, you have to have a:

__init__.py 

file (empty is fine, just use "touch init.py") in every directory leading to your app that is in the python path.

So if you have a structure like this:

my_project/
    manage.py
    __init__.py
    urls.py
    settings.py
    apps/
        __init__.py <---- this has to be here
        midi_app/
            __init__.py <--- this also has to be here
            models.py
            admin.py
            views.py
            urls.py

It's simple thing to overlook.