python ./store/manage.py runserver
当我跑这个时,我得到了这样的错误:
$ python ./store/manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x0000000003AE6978>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\core\management\commands\runserver.py", line 113, in inner_run
autoreload.raise_last_exception()
File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\utils\autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named polls
答案 0 :(得分:0)
我测试了一些案例,唯一一个我遇到同样错误的案例是当我将项目中不存在的应用添加到INSTALLED_APPS
文件中的settings.py
时。因此,请确保您使用polls
创建了python manage.py startapp polls
个应用(您应该拥有/store/polls
文件夹)。
要创建polls
应用,如果它不存在,您需要先将其从INSTALLED_APPS
中删除。如果不先删除它,您将得到与上面相同的错误。
此外,在运行任何命令之前,您需要cd到项目根文件夹(即使上述命令不需要它),所以代替:
python ./store/manage.py runserver
执行命令
cd store/
python manage.py runserver