首页 > 解决方案 > 在 Windows 10 中安装 mysqlclient 或/和 mysql-python 时出错

问题描述

我在 Windows 10 Home 的文件夹中正确安装了 Django,我需要将此应用程序与 Mysql 连接。当我执行 pip install mysqlclient 或/和 mysql-python 我有这个错误。

_mysql.c
_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

----------------------------------------
Command "c:\xampp\htdocs\worldfeeding\env\scripts\python.exe -u -c "import 
setuptools, tokenize;__file__='C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-ceju8r0r\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\user\AppData\Local\Temp\pip-record-r4bwaq6w\install-record.txt --single-version-externally-managed --compile --install-headers c:\xampp\htdocs\worldfeeding\env\include\site\python3.7\mysqlclient" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-install-ceju8r0r\mysqlclient\

搜索,我尝试了以下答案中的解决方案:

错误:命令 'C:\\Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' 失败,退出状态为 2

Python pip 安装错误:命令 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' 失败,退出状态为 2

但不工作。

因此,我按照这些链接中答案的说明安装了 Visual Studio Community 2017 的 paquets,但无法正常工作。

我用 mysql 服务器安装了 mysql-web-community。

我下载了 VS 和 Twisted-18.4.0-cp36-cp36m-win32.whl 但无法正常工作。

我尝试使用 npm install --global --production windows-build-tools 并没有。

有人可以帮助我吗?

标签: pythonmysqlpip

解决方案


推荐阅读