0

我正在使用 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 我很困惑我是否将此命令绑定在正确的目录中。 任何帮助!

4

2 回答 2

3

你安装了MySQLdb吗?这是一个系统库。谷歌上的快速搜索显示了几个网站,您可以从中下载

其中之一是(从此处提取的链接),另一个解决此问题的帖子

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

http://sourceforge.net/projects/mysql-python/files/mysql-python/

于 2013-05-23T13:35:16.013 回答
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/

于 2013-05-23T14:40:44.143 回答