首页 > 解决方案 > 致命错误 C1083:无法打开包含文件:'mysql.h':没有此类文件或目录错误

问题描述

已经尝试了论坛中的所有内容,但对我来说没有任何效果,如果您提供解释,我是一个nube,我想要一个详细的解释。请帮忙找出问题。我已尝试上传车轮在此处输入图像描述

我试图在 \Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb 和 \Program Files (x86)\MySQL\MySQL Connector C 6.1\lib\mariadb 中实现 MariaDB

但是对我来说没有任何效果。

 PS C:\Users\info\Desktop\storefront> pipenv install mysqlclient
 Installing mysqlclient...
 Error:  An error occurred while installing mysqlclient!
 Error text: Collecting mysqlclient
 Using cached mysqlclient-2.0.3.tar.gz (88 kB)
 Preparing metadata (setup.py): started
 Preparing metadata (setup.py): finished with status 'done'
 Building wheels for collected packages: mysqlclient
 Building wheel for mysqlclient (setup.py): started
 Building wheel for mysqlclient (setup.py): finished with status 'error'
 Running setup.py clean for mysqlclient
 Failed to build mysqlclient
 Installing collected packages: mysqlclient
 Running setup.py install for mysqlclient: started
 Running setup.py install for mysqlclient: finished with status 'error'

 ERROR: Command errored out with exit status 1:
 command: 'C:\Users\info\.virtualenvs\storefront-ncd4CFf2\Scripts\python.exe' -u -c 'import 
 io, os, sys, setuptools, tokenize; sys.argv[0] = 
 '"'"'C:\\Users\\info\\AppData\\Local\\Temp\\pip-install- 
 teckkm52\\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\\setup.py'"'"'; 
 __file__='"'"'C:\\Users\\info\\AppData\\Local\\Temp\\pip-install- 
 teckkm52\\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\\setup.py'"'"';f = getattr(tokenized, 
 '"'"'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'"'"'))' bdist_wheel -d 
 'C:\Users\info\AppData\Local\Temp\pip-wheel-x6tij91j'
   cwd: C:\Users\info\AppData\Local\Temp\pip-install- 
 teckkm52\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\       
 Complete output (31 lines):
 running bdist_wheel
 running build
 running build_py
 creating build
 creating build\lib.win32-3.9
 creating build\lib.win32-3.9\MySQLdb
 copying MySQLdb\__init__.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\_exceptions.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\connections.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\converters.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\cursors.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\release.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\times.py -> build\lib.win32-3.9\MySQLdb
 creating build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\__init__.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\CR.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\ER.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.9\MySQLdb\constants
 warning: build_py: byte-compiling is disabled, skipping.

 running build_ext
 building 'MySQLdb._mysql' extension
 creating build\temp.win32-3.9
 creating build\temp.win32-3.9\Release
 creating build\temp.win32-3.9\Release\MySQLdb
 C:\Program Files (x86)\Microsoft Visual 
Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\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\info\.virtualenvs\storefront- 
ncd4CFf2\include -Ic:\users\info\appdata\local\programs\python\python39-32\include - 
Ic:\users\info\appdata\local\programs\python\python39-32\include -IC:\Program Files 
(x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include -IC:\Program 
Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows 
Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows 
Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows 
Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows 
Kits\10\include\10.0.19041.0\cppwinrt /TcMySQLdb/_mysql.c /Fobuild\temp.win32- 
3.9\Release\MySQLdb/_mysql.obj
_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\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x86\\cl.exe' failed with 
exit code 2
----------------------------------------
 ERROR: Failed building wheel for mysqlclient
 ERROR: Command errored out with exit status 1:
 command: 'C:\Users\info\.virtualenvs\storefront-ncd4CFf2\Scripts\python.exe' -u -c 'import 
 io, os, sys, setuptools, tokenize; sys.argv[0] = 
 '"'"'C:\\Users\\info\\AppData\\Local\\Temp\\pip- 
 install-teckkm52\\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\\setup.py'"'"'; 
 __file__='"'"'C:\\Users\\info\\AppData\\Local\\Temp\\pip-install- 
 teckkm52\\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\\setup.py'"'"';f = getattr(tokenized, 
 '"'"'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\info\AppData\Local\Temp\pip-record-mee486wg\install-record.txt' --single-version- 
 externally-managed --compile --install-headers 'C:\Users\info\.virtualenvs\storefront- 
 ncd4CFf2\include\site\python3.9\mysqlclient'
      cwd: C:\Users\info\AppData\Local\Temp\pip-install- 
 teckkm52\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\     
 Complete output (33 lines):
 running install
 C:\Users\info\.virtualenvs\storefront-ncd4CFf2\lib\site- 
 packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is 
 deprecated. Use build and pip and other standards-based tools.
   warnings.warn(
 running build
 running build_py
 creating build
 creating build\lib.win32-3.9
 creating build\lib.win32-3.9\MySQLdb
 copying MySQLdb\__init__.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\_exceptions.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\connections.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\converters.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\cursors.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\release.py -> build\lib.win32-3.9\MySQLdb
 copying MySQLdb\times.py -> build\lib.win32-3.9\MySQLdb
 creating build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\__init__.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\CR.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\ER.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.9\MySQLdb\constants
 copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.9\MySQLdb\constants
 warning: build_py: byte-compiling is disabled, skipping.

 running build_ext
 building 'MySQLdb._mysql' extension
 creating build\temp.win32-3.9
 creating build\temp.win32-3.9\Release
 creating build\temp.win32-3.9\Release\MySQLdb
 C:\Program Files (x86)\Microsoft Visual 
 Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\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\info\.virtualenvs\storefront- 
 ncd4CFf2\include -Ic:\users\info\appdata\local\programs\python\python39-32\include - 
 Ic:\users\info\appdata\local\programs\python\python39-32\include -IC:\Program Files 
 (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include -IC:\Program 
 Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows 
 Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows 
 Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows 
 Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows 
 Kits\10\include\10.0.19041.0\cppwinrt /TcMySQLdb/_mysql.c /Fobuild\temp.win32- 
 3.9\Release\MySQLdb/_mysql.obj
 _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\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x86\\cl.exe' failed 
  with exit code 2
  ----------------------------------------
 ERROR: Command errored out with exit status 1: 'C:\Users\info\.virtualenvs\storefront- 
 ncd4CFf2\Scripts\python.exe' -u 
 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = 
 '"'"'C:\\Users\\info\\AppData\\Local\\Temp\\pip-install- 
 teckkm52\\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\\setup.py'"'"'; 
 __file__='"'"'C:\\Users\\info\\AppData\\Local\\Temp\\pip-install- 
 teckkm52\\mysqlclient_916f3b56813c4e1c90eea8491caf2c2c\\setup.py'"'"';f = getattr(tokenized, 
 '"'"'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 -all --record 
 'C:\Users\info\AppData\Local\Temp\pip-record-mee486wg\install-record.txt' --single-version- 
  externallaged y-managed --compile --install-headers 'C:\Users\info\.virtualenvs\storefront- 
  ncd4CFf2\include\site\python3.9\mysqheck lclient' Check the logs for full command output.
  [==  ] Installing mysqlclient...
  Installation Failed
 
  PS C:\Users\info\Desktop\storefront> python --
  Python 3.9.4 (tags/v3.9.4:1f2e308, Apr  6 2021, 13:22:44) [MSC v.1928 32 bit (Intel)] on 
  win32
  **strong text**strong text Type "help", "copyright", "credits" or "license" for more information.
  >>> 

附加信息:我尝试了几次安装轮子,我找到了正确的轮子,但是当我尝试检查我与 mysql 的连接时,前提是术语“mysql”未被识别为 cmdlet、函数、脚本文件的名称,或可运行的程序。

enter code here
PS C:\Users\info\Desktop\storefront> pipenv install mysqlclient-1.4.6- 
cp36- 
cp36m-win32.whl
Installing mysqlclient-1.4.6-cp36-cp36m-win32.whl...
Error:  An error occurred while installing mysqlclient-1.4.6-cp36-cp36m- 
win32.whl!
Error text:
ERROR: mysqlclient-1.4.6-cp36-cp36m-win32.whl is not a supported wheel 
on this platform.

Installation Failed
    
PS C:\Users\info\Desktop\storefront> pipenv install mysqlclient-1.4.6- 
cp39-cp39-win_amd64.whl
Installing mysqlclient-1.4.6-cp39-cp39-win_amd64.whl...
Error:  An error occurred while installing mysqlclient-1.4.6-cp39-cp39- 
win_amd64.whl!
Error text:
ERROR: mysqlclient-1.4.6-cp39-cp39-win_amd64.whl is not a supported 
wheel on this platform.

Installation Failed

PS C:\Users\info\Desktop\storefront> pipenv install mysqlclient-1.4.6- 
cp39-cp39-win32.whl
Installing mysqlclient-1.4.6-cp39-cp39-win32.whl...
Adding mysqlclient to Pipfile's [packages]...
Installation Succeeded
Installing dependencies from Pipfile.lock (a84cc7)...
================================ 1/1 - 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
PS C:\Users\info\Desktop\storefront> mysql -u root -p
mysql : The term 'mysql' is not recognized as the name of a cmdlet, 
function, script file, or operable program. 
Check the spelling of the name, or if a path was included, verify that 
the path is correct and try again.
At line:1 char:1
+ mysql -u root -p
+ ~~~~~
+ CategoryInfo          : ObjectNotFound: (mysql:String) [], 
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

标签: pythonmysql-connector

解决方案


推荐阅读