Error loading MySQLdb module: No module named MySQLdb 错误的解决方法

具体报错如下:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

解法办法:

需要安装python连接mysql的模块

注意:本人使用yum install MySQL-pyton安装后依然报上错误,经测试必须要pip方式安装

pip install mysql-python

如果安装报以下错误:

pip install pandas` gives UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe2 in position 41: ordinal not in range(128)

则需要升级pip版本:

pip install --upgrade pip

升级完成后重装安装mysql-python

pip install mysql-python

如果安装报以下错误:

_mysql.c:2091: error: ‘r’ undeclared (first use in this function)

_mysql.c:2091: error: ‘_mysql_ResultObject’ has no member named ‘result’

_mysql.c:2092: error: ‘_mysql_ResultObject’ has no member named ‘result’

_mysql.c: In function ‘_mysql_ResultObject_dealloc’:

_mysql.c:2100: warning: implicit declaration of function ‘mysql_free_result’

_mysql.c:2100: error: ‘_mysql_ResultObject’ has no member named ‘result’

_mysql.c: At top level:

_mysql.c:2331: error: ‘_mysql_ConnectionObject’ has no member named ‘open’

_mysql.c:2338: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’

_mysql.c:2345: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’

_mysql.c:2352: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’

_mysql.c:2359: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’

_mysql.c:2422: error: ‘_mysql_ResultObject’ has no member named ‘converter’

_mysql.c:2422: error: initializer element is not constant

_mysql.c:2422: error: (near initialization for ‘_mysql_ResultObject_memberlist[0].offset’)

_mysql.c: In function ‘_mysql_ConnectionObject_getattr’:

_mysql.c:2444: error: ‘_mysql_ConnectionObject’ has no member named ‘open’

error: command ‘gcc‘ failed with exit status 1

解决方法:yum -y install mysql-devel libxml2 libxml2-dev libxslt* zlib gcc openssl

安装完成后再次尝试安装mysql-python

pip install mysql-python

[[email protected] Craxsxx]# pip install mysql-python

Collecting mysql-python

Using cached MySQL-python-1.2.5.zip

Installing collected packages: mysql-python

Running setup.py install for mysql-python

Successfully installed mysql-python-1.2.5

mysql-python的模块安装成功

时间: 2024-10-09 04:14:24

Error loading MySQLdb module: No module named MySQLdb 错误的解决方法的相关文章

c++中调用python脚本提示 error LNK2001: 无法解析的外部符号 __imp_Py_Initialize等错误的解决方法

最近项目中需要实现一个服务器宕机后短信提醒的功能,个人觉得在使用Python 写http请求这块很方便,发短信这块就使用了python,但是c++程序中调用这个脚本时,编译不通过,提示如下错误: error LNK2001: 无法解析的外部符号 __imp_PyString_FromStringerror LNK2001: 无法解析的外部符号 __imp_PyCallable_Check error LNK2001: 无法解析的外部符号 __imp_PyObject_CallObjecterro

No module named yum错误的解决办法

今天用yum安装软件的时候出现如下错误: There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named yum Please install a package which provides this module, or verify that the module is installed c

类似No module named 'bs4'等错误的解决方法

最近开始接触爬虫,写了如下源代码: from bs4 import BeautifulSoup import requests url='https://www.tripadvisor.cn/Attractions-g60763-Activities-New_York_City_New_York.html' wb_date=requests.get(url) soup=BeautifulSoup(wb_date.text,'lxml') print(soup) 但是开头引用的"from bs4 

【Python 脚本报错】AttributeError: 'module 'yyy' has no attribute 'xxx'的解决方法

先参考这篇记录大概理解了原因, 再深入了解下python的import机制, 发现自己的模块之间存在互相import. 比如,A.py中import B,而B.py中也import A了, 现在执行模块A,就会先将B中的代码搬过来,但B中有import A,而此时A.pyc还没生成,所以B中import A之后的代码也执行不了: 如果mode B 的 attribute xxx是定义在import A之后,那么就会出现题目中的报错: (而python是解释性语言,所以import A之前的代码还

Intellij-出现Module ** must not contain source root **. The root already belongs to module **这类错误的解决方法

出现这个问题的原因是,多模块Maven项目,parent目录不能不能有src的code.找到parent 的 Source Folders看看是否把module的给加载进来了.删掉就可以了. 参考: [1]IDEA出现Module ** must not contain source root **. The root already belongs to module **这类错误的解决方法 原文地址:https://www.cnblogs.com/happyflyingpig/p/12267

飞鸽传书 bind() error=10048错误的解决方法

提示  bind() 错误=10048 原因:其他程序占用飞鸽的 2425 端口 比如:飞秋也是使用2425端口 解决:用netstat命令查看是哪个进程占用了该端口 格式:netstat -ano | find "2425" 结果:  UDP    0.0.0.0:2425     *:*        1716 最后的1716就是占用2425进程的进程ID,看看是什么,可以结束的直接结束该进程,再打开飞鸽就可以了. 关于netstat命令可以输入命令 netstat /? 查看更多

window10 安装出现the error code is 2503错误的解决方法

window10 安装出现the error code is 2503错误的解决方法: 设置 C:\WINDOWS\TEMP的权限

navicat连接oracle数据库报ORA-28547: connection to server failed, probable Oracle Net admin error错误的解决方法

原文:navicat连接oracle数据库报ORA-28547: connection to server failed, probable Oracle Net admin error错误的解决方法 navicat是通过oracle客户端连接oracle服务器的. oracle的客户端有两种,一种标准的客户端安装程序,下载地址: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost'的解决方法

[mysql]ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost'的解决方法 在安装完MySQL并添加环境变量之后 由于在MySQL安装过程中设置了密码,导致直接在cmd中登陆出现了上面问题, 解决方式: 正确的cmd登陆命令应该如下所示(红字部分):之后会提示输入密码 即可进入MySQL C:\users\Laoyu_>mysql -u root -p Enter password: ******(输入你的密码) (图见附件

VC6的工程转到VC2010或更高版本出现fatal error C1189编译错误的解决方法

以前也遇到过,当时解决了没写下来,这次正好又遇到了,就顺手写一下吧,别下次又忘记了. 当VC6的工程转到VC2010或更高版本时编译出现如下错误: c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxver_.h(81): fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds 很多解决方法是把工程属性中的“常规”-“MFC