MySQLdb/_mysql.c(29):致命错误 C1083:无法打开包含文件:'mysql.h':没有这样的文件或目录

Posted

技术标签:

【中文标题】MySQLdb/_mysql.c(29):致命错误 C1083:无法打开包含文件:\'mysql.h\':没有这样的文件或目录【英文标题】:MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directoryMySQLdb/_mysql.c(29):致命错误 C1083:无法打开包含文件:'mysql.h':没有这样的文件或目录 【发布时间】:2019-08-07 12:53:34 【问题描述】:

我正在尝试在 django virtualenv 中安装 mysqlclient。但是我得到了这个错误

Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... error
  Complete output from command c:\users\adity\desktop\dev\blog\env\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\adity\\AppData\\Local\\Temp\\pip-install-wxr9hw0f\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\adity\AppData\Local\Temp\pip-wheel-zjrz983m --python-tag cp37:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.7
  creating build\lib.win32-3.7\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
  copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
  creating build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build\temp.win32-3.7
  creating build\temp.win32-3.7\Release
  creating build\temp.win32-3.7\Release\MySQLdb
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -Ic:\users\adity\appdata\local\programs\python\python37-32\include -Ic:\users\adity\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
  _mysql.c
  MySQLdb/_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 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

  ----------------------------------------
  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command c:\users\adity\desktop\dev\blog\env\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\adity\\AppData\\Local\\Temp\\pip-install-wxr9hw0f\\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\adity\AppData\Local\Temp\pip-record-wtvbzmsb\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\adity\desktop\dev\blog\env\include\site\python3.7\mysqlclient:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -Ic:\users\adity\appdata\local\programs\python\python37-32\include -Ic:\users\adity\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_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 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\users\adity\desktop\dev\blog\env\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\adity\\AppData\\Local\\Temp\\pip-install-wxr9hw0f\\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\adity\AppData\Local\Temp\pip-record-wtvbzmsb\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\adity\desktop\dev\blog\env\include\site\python3.7\mysqlclient" failed with error code 1 in C:\Users\adity\AppData\Local\Temp\pip-install-wxr9hw0f\mysqlclient\

我确实在***上找到了一些在线解决方案,他们说mysqlclient不支持python 3.7 我需要从this site安装***

我确实尝试安装 whl 文件。但是 plb 是我无法在 virtualenv 中安装,当我尝试在虚拟环境中安装它时,我得到类似这样的错误

mysqlclient-1.4.2-cp37-cp37m-win_amd64.whl 不是这个平台支持的***。

我该如何解决这个问题? 我需要在服务器上的 sql 数据库上部署我的应用程序。

【问题讨论】:

"Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python的可能重复 【参考方案1】:

我在similar question找到了答案(如果不是重复的话)

“Σωτήρης Τσακιρίδης”说:

尝试在 64 位环境中为 python32 安装 mysqlclient 时发生此错误。卸载python并重新安装64位版本。然后 pip install mysqlclient 将运行没有错误。

如果您使用pyenv 进行Python 管理,请在您的项目文件夹中运行命令,例如:

pyenv local 3.6.8-amd64

【讨论】:

以上是关于MySQLdb/_mysql.c(29):致命错误 C1083:无法打开包含文件:'mysql.h':没有这样的文件或目录的主要内容,如果未能解决你的问题,请参考以下文章

MySQLdb 安装错误 - _mysql.c:44:23: error: my_config.h: No such file or directory

我在窗口 10 64bit 上使用 pip install flask-mysqldb 时遇到问题,出现错误

python2安装Flask-MySQLdb出现 fatal error C1083: Cannot open include file: 'mysql.h': No su ch fi

致命错误:Python.h:没有这样的文件或目录错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1

错误:xkeycheck.h(179):警告 C4005:'char16_t':宏重新定义” |致命错误 C1189

Django MySQLdb 版本与 _mysql 版本不匹配 Ubuntu