Python 安装mysqlclient 错误MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: 解决方法

错误提示:

ERROR: Command errored out with exit status 1:
command: ‘c:\users\30452\appdata\local\programs\python\python38-32\python.exe’
-u -c ‘import io , os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\30452\AppData\Local\Temp\pip-inst
all-d6s_2g4l\mysqlclient_2da381d847214b0193d0cd589a21eaa2\setup.py’"’"’;
file=’"’"‘C:\Users\ 30452\AppData\Local\Temp\pip-install-d6s_2g4l\mysqlclient_2da381d847214b0193d0cd589a21eaa2\set
up.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if
os.path.exists(file) else io .StringIO(’"’"‘from setuptools import
setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ’
“’”’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’
install --record ‘C:\Users\304
52\AppData\Local\Temp\pip-record-excl1aq1\install-record.txt’
–single-version-externally-managed – compile --install-headers ‘c:\users\30452\appdata\local\programs\python\python38-32\Include\mysqlcli
ent’
cwd: C:\Users\30452\AppData\Local\Temp\pip-install-d6s_2g4l\mysqlclient_2da381d847214b0193d
0cd589a21eaa2
Complete output (31 lines):
Error in sitecustomize; set PYTHONVERBOSE for traceback:
AttributeError: module ‘sys’ has no attribute ‘setdefaultencoding’
running install
running build
running build_py
creating build
creating build\lib.win32-3.8
creating build\lib.win32-3.8\MySQLdb
copying MySQLdb_init_.py -> build\lib.win32-3.8\MySQLdb
copying MySQLdb_exceptions.py -> build\lib.win32-3.8\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb
creating build\lib.win32-3.8\MySQLdb\constants
copying MySQLdb\constants_init_.py -> build\lib.win32-3.8\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants
running build_ext
building ‘MySQLdb.mysql’ extension
creating build\temp.win32-3.8
creating build\temp.win32-3.8\Release
creating build\temp.win32-3.8\Release\MySQLdb
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\Host
X86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD
-Dversion_info=(2,0,3,‘final’,0) -D__version
_=2.
0.3 “-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb” -Ic:\users\30452\appdata\ local\programs\python\python38-32\include
-Ic:\users\30452\appdata\local\programs\python\python38-32 \include “-IC:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ ATLMFC\include”
“-IC:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.25 .28610\include”
“-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um”
“-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt”
“-IC:\Program Files (x86)\Windows Kits\10\include\1
0.0.18362.0\shared” “-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um” “-IC:\Program Files (x86)\Windows
Kits\10\include\10.0.18362.0\winrt” “-IC:\Program Files (x86)\Windows
Kits\10\i nclude\10.0.18362.0\cppwinrt” /TcMySQLdb/_mysql.c
/Fobuild\temp.win32-3.8\Release\MySQLdb/_mysql.obj
_mysql.c
MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or director y
error: command ‘C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MS
VC\14.25.28610\bin\HostX86\x86\cl.exe’ failed with exit status 2
---------------------------------------- ERROR: Command errored out with exit status 1:
‘c:\users\30452\appdata\local\programs\python\python3 8-32\python.exe’
-u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\3045
2\AppData\Local\Temp\pip-install-d6s_2g4l\mysqlclient_2da381d847214b0193d0cd589a21eaa2\setup.py’"’"’;
file=’"’"‘C:\Users\30452\AppData\Local\Temp\pip-install-d6s_2g4l\mysqlclient_2da381d847214b
0193d0cd589a21eaa2\setup.py’"’"’;f = getattr(tokenize,
‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else
io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code =
f.read().replace(’"’" ‘\r\n’"’"’,
‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’
install --record
‘C:\Users\30452\AppData\Local\Temp\pip-record-excl1aq1\install-record.txt’
–single-version-externally-managed --compile --install-headers ‘c:\users\30452\appdata\local\programs\python\python38-32\Include\mysqlclient’
Check the logs for full command output
在这里插入图片描述

打开网页:https://www.lfd.uci.edu/~gohlke/pythonlibs
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
在这里插入图片描述
cp39-cp39 cp后面数字代表Python版本
win32 代表Python为32位
下载对应版本
在这里插入图片描述
cd 进入下载的文件目录
pip install +文件名进行安装

其他包安装失败 方法通用

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小旺不正经

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值