在 django 中运行syncdb时出现问题
我正在尝试浏览 django 文档教程,但在同步 mysql 时遇到问题。在命令 python manage.pysyncdb
上,我收到以下错误(注意我在 Windows 7 中运行):
...
File "C:\python27\lib\site-packages\django\db\backends\mysql\base.py", line 14, in <module>
raise Improperlyconfigured("Error loading Mysqldb module: %s" % e)
django.core.excepions.Improperlyconfigured: Error loading Mysqldb module: No module named mySQLdb
我已将 settings.py 中的数据库初始化为:
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysite', #the name I gave in Mysql with 'CREATE DATABASE mysite;'
'USER': 'root',
'PASSWORD': 'mypassword', # as set in MysqlInstanceConfig
'HOST': '',
'PORT': '',
那么如何让syncdb运行正确吗?缺少模块错误是什么意思以及如何纠正它?
I am trying to go through the django docs tutorial and having a problem syncing mysql. On the command python manage.py syncdb
I get the following error (note I'm running in windows 7):
...
File "C:\python27\lib\site-packages\django\db\backends\mysql\base.py", line 14, in <module>
raise Improperlyconfigured("Error loading Mysqldb module: %s" % e)
django.core.excepions.Improperlyconfigured: Error loading Mysqldb module: No module named mySQLdb
I have initialized the db in setting.py as:
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysite', #the name I gave in Mysql with 'CREATE DATABASE mysite;'
'USER': 'root',
'PASSWORD': 'mypassword', # as set in MysqlInstanceConfig
'HOST': '',
'PORT': '',
So how do I get syncdb to run correctly? What does the missing module error mean and how do I correct it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要安装 python mysql 库。
这是django相关的 在 Windows 上执行此操作的指南
You need to install the python mysql library.
Here is a django-related guide to do this on windows
您必须安装 mySQLdb 模块。
You have to install the mySQLdb module.
您很可能还没有安装处理 mysql 连接的 Python 模块。你可以通过 Cheeseshop 使用 pip 或 easy_install 安装它,它被称为 MySQL-python。
You most probably haven't installed the Python module that handles the mysql connections. You can install it through the Cheeseshop with pip or easy_install and it's called MySQL-python.