ImportError cannot import name

58 views
Skip to first unread message

Juan Carlos

unread,
Oct 22, 2014, 12:16:25 AM10/22/14
to django...@googlegroups.com
Hi everyone,

When I execute the command:

python manage.py runserver &

The response is:

Traceback (most recent call last):
  File "../manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/usr/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/lib/python2.7/site-packages/django/apps/config.py", line 120, in create
    "cannot import name '%s' from '%s'" % (cls_name, mod_path))
ImportError: cannot import name 'example' from 'exsite'


In settings.py I have:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'exsite.example',
)


If I comment (#) the last line, the bug dissapears.  ¿What can I do?  I have Django 1.7 with Python 2.7.  Thanks for your attention.

Regards,
Juan

Sabine Maennel

unread,
Oct 22, 2014, 7:38:24 AM10/22/14
to django...@googlegroups.com
Hello Juan, if your project is "exsite" and your app is "example" then you should probably just add "example" to the list of installed apps. Try it, hope it works.
        with kind regards
            Sabine

Sabine Maennel

unread,
Oct 23, 2014, 12:02:20 AM10/23/14
to django...@googlegroups.com
Hello Juan,

I think your settings file should look like this:
In settings.py I have:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'example',
)


but to be sure I would need to see you directory structure. Hope this helps. 
    with kind regards
         Sabine
Reply all
Reply to author
Forward
0 new messages