加载MySQLdb模块时出错'您安装了mysqlclient还是MySQL-python? [英] Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'
问题描述
我正在将Windows 10命令行用于使用python34的django项目,但是,我在使用SQL时遇到了困难.
I am using windows 10 command line for a django project using python34 however, I am facing difficulties with SQL.
我已经使用pip install mysqlclient==1.3.5
安装了mysqlclient并找到了该文件以确保我没有妄想.然后,我运行python manage.py migrate
将表迁移到SQL数据库(我正在使用phpmyadmin).但是,当命令返回时...
I have already installed mysqlclient using pip install mysqlclient==1.3.5
and located the file to make sure I was not delusional. I then ran python manage.py migrate
to migrate the tables to the SQL database (I am using phpmyadmin). However when the command returned with...
File "C:\Users\user\env\lib\site-packages\django\db\backends\mysql\base.py", line 30, in <module>
'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
Did you install mysqlclient or MySQL-python?
我知道这样的问题已经存在,但是似乎没有一种解决方案对尝试产生任何影响.预先谢谢你.
I am aware that questions like these already exist, but not one solution seems to have made any impact on attempts. Thank you in advance.
推荐答案
pip install pymysql
然后,在项目原始目录(与settings.py相同)中编辑__init__.py文件
Then, edit the __init__.py file in your project origin dir(the same as settings.py)
添加:
import pymysql
pymysql.install_as_MySQLdb()
这篇关于加载MySQLdb模块时出错'您安装了mysqlclient还是MySQL-python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!