我正在尝试在djangoproject.com网站上进行Django教程,但是当我到达第一个“makemigrations polls”部分时,我一直收到此错误:
“ImportError: No module named apps”
如何解决这个错误?
“ImportError: No module named apps”
如何解决这个错误?
Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 312, in execute django.setup() File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Library/Python/2.7/site-packages/django/apps/config.py", line 112, in create mod = import_module(mod_path) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name)
python -m django --version
时,会出现以下错误信息:/usr/bin/python: No module named django.main; 'django' is a package and cannot be directly executed。 - Monilpython -m django --version
适用于 Django 1.9 及以上版本。对于早期版本,您可以执行python -c 'import django; print(django.VERSION)'
- Alasdair