Error loading MySQLdb Module #39;Did you install mysqlclient or MySQL-python?#39;(加载 MySQLdb 模块时出错“您安装了 mysqlclient 还是 MySQL-python?)
问题描述
我在使用 python34 的 django 项目中使用 windows 10 命令行,但是,我在使用 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:Usersuserenvlibsite-packagesdjangodbackendsmysqlase.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
然后,在你的项目源目录中编辑__init__.py文件(与settings.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?"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:加载 MySQLdb 模块时出错“您安装了 mysqlclient 还是 MySQL-python?"
基础教程推荐
- oracle区分大小写的原因? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在多列上分布任意行 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
