Ich habe ein Projekt sagen MyProject
mit der angegebenen Verzeichnisstruktur, wo die Anwendungen im Verzeichnis applications
installiert sind.Django 1.9 ImportError: Kein Modul mit dem Namen 'appname' auf der Shell
.
├── myapp
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── settings.py
│ ├── settings.pyc
│ ├── urls.py
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
├── applications
│ └── polls
│ ├── admin.py
│ ├── apps.py
│ ├── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── db.sqlite3
├── manage.py
└── wsgi
├── static
│ └── keep.me
└── wsgi.py
Mein polls/apps.py
Inhalt ist
from __future__ import unicode_literals
from django.apps import AppConfig
class PollConfig(AppConfig):
name = 'applications.polls'
und der polls/__init__.py
Inhalt,
default_app_config='applications.polls.apps.PollConfig'
und die INSTALLED_APPS
in Einstellungen,
INSTALLED_APPS = [
......
......
'applications.polls'
]
die Schale wirft ImportError: No module named polls
Wie behebe ich es?
vielen Dank.
Update (fügt Traceback)
Traceback (most recent call last):
File "<input>", line 5, in <module>
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/apps/config.py", line 123, in create
import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/opt/pycharm-5.0.3/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named polls
Update: Python manage.py Shell Zurückverfolgungs
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/marty/.virtualenvs/dj19/local/lib/python2.7/site-packages/django/core/management/commands/shell.py", line 101, in handle
code.interact(local=imported_objects)
AttributeError: 'module' object has no attribute 'interact'
oder in Ihrer INSTALLED_APPS, einfach 'Umfragen' – harryr
OP verwendet ein einziges Paket, um alle Anwendungen zu enthalten, weshalb er 'applications.polls' verwendet. – v1k45
oops, das ist nur ein Tippfehler Ich habe tatsächlich eine Init-Datei dort. habe andere Apps ausgelassen. mit '__inti __. py' bekomme ich den gleichen Fehler. – Marty