运行以下命令
$python2.6 manage.py runserver
给出一个输出:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
我尝试了许多解决方案,但它们没有用。
当我尝试使用 pip 再次安装 django 时,
$ pip install django
它给出以下输出:
Requirement already satisfied (use --upgrade to upgrade): django in /Library/Python/2.7/site-packages
Cleaning up...
并尝试
$ pip freeze
给出以下输出,
Django==1.5.4
MySQL-python==1.2.4
...
...
...
wsgiref==0.1.2
xattr==0.6.2
zope.interface==3.5.1
我不知道该怎么办?请帮助我浪费了整个尝试成功运行它。谢谢。
更新:
当我尝试跑步时
$ python2.7 manage.py runserver
它给了我以下错误
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x107e63050>>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 92, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 28, in get_validation_errors
from django.db import models, connection
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/tg/.python-eggs/MySQL_python-1.2.4-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/tg/.python-eggs/MySQL_python-1.2.4-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so
Reason: image not found