我使用aptana使用django创建网站。我已经安装了mysql,但是当我运行此命令时无法链接数据库*Python2.7 manage.py runserver*
我收到一条消息,说明Python2.7无法识别,当我运行此命令时 Python manage.py runserver
我收到一条错误消息
C:\Users\George\Documents\Aptana Studio 3 Workspace\Firstwebsite>python manage.py runserver
验证模型......
Unhandled exception in thread started by <bound method Command.inner_run of <dja
ngo.contrib.staticfiles.management.commands.runserver.Command object at 0x028E5C
70>>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line
92, in inner_runself.validate(display_num_errors=True)
`File "C:\Python27\lib\site-packages\django\core\management\base.py", line 280, in
validate num_errors = get_validation_errors(s, app)`
File "C:\Python27\lib\site-packages\django\core\management\validation.py", line 28, in
get_validation_errors from django.db import models, connection
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in
import_module__import__(name)
File "C:\Python27\lib\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: No module
named MySQLdb
我正在使用Django 1.5和python 2.7以及aptana 3 我很困惑我是否将这些命令绑定在正确的目录中。 任何帮助!!!
答案 0 :(得分:3)
您安装了MySQLdb
吗?这是一个系统库。在谷歌上快速搜索显示几个网站,您可以从
其中一个是(从here拉出的链接),另一个post解决了这个问题:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
http://sourceforge.net/projects/mysql-python/files/mysql-python/
答案 1 :(得分:1)
我们需要查看您的settings.py文件以进行更深入的审核。
从表面上看,您似乎没有将其链接到设置文件中的数据库。这是一个可以帮助您安装它的链接:
http://decoding.wordpress.com/2012/01/23/how-to-setup-django-and-mysql-python-on-mac-os-x-lion/
(至少在MAC / Unix上.Windows是另一回事)
之后,我会按照任何关于将两者联系起来的指南。
(博客上的一些通用版)
http://nisthaonweb.com/blog/2012/02/setting-up-django-with-mysql-with-and-without-mamp/