win7 amd cpu的安装python pip 安装 mysql组件失败 “mysql.h”: No such file or directory ‘ failed with exit code

从你提供的信息来看,安装 mysqlclient 时仍然遇到了相同的错误,即找不到 mysql.h 文件。这表明之前的解决方案可能没有完全解决问题。让我们再次检查并尝试一些其他方法。

1. 确认 MariaDB Connector/C 的安装

确保你已经正确安装了 MariaDB Connector/C,并且路径配置正确。你可以按照以下步骤进行检查和安装:

  1. 下载并安装 MariaDB Connector/C

    • 访问 MariaDB 官网 下载适合你操作系统的 MariaDB Connector/C。

    • 选择适合 Windows 的版本并下载安装包。

  2. 安装 MariaDB Connector/C

    • 运行下载的安装包并按照提示完成安装。

    • 确保安装路径包含 includelib 目录。

  3. 配置环境变量

    • 打开系统环境变量设置。

    • 添加或修改 INCLUDELIB 环境变量,确保它们包含 MariaDB Connector/C 的 includelib 目录。

    例如:

    plaintext复制

    INCLUDE=C:\Program Files\MariaDB\MariaDB Connector C\include;mariadb;%INCLUDE%
    LIB=C:\Program Files\MariaDB\MariaDB Connector C\lib;mariadb;%LIB%

2. 重新尝试安装

配置好环境变量后,重新尝试安装 mysqlclient

sh复制

pip install mysqlclient

3. 使用预编译的轮子

如果上述方法仍然失败,你可以尝试使用预编译的轮子。你可以从 Unofficial Windows Binaries for Python Extension Packages 下载适合你 Python 版本的 mysqlclient 轮子。

  1. 下载对应的 .whl 文件

  2. 使用 pip 安装

    • 下载轮子文件后,使用 pip 安装:

      sh复制

      pip install path_to_downloaded_wheel_file.whl

4. 检查网络问题

你提到的链接解析失败可能是由于网络问题或链接本身的问题。请确保以下几点:

  1. 检查链接的合法性

    • 确保链接地址正确无误,没有拼写错误。

    • 尝试在浏览器中直接访问这些链接,看是否能正常下载文件。

  2. 重试网络连接

    • 确保你的网络连接稳定。

    • 重试下载和安装操作。

5. 其他解决方案

如果上述方法仍然无法解决问题,可以参考以下链接中的解决方案:

希望这些步骤能帮助你解决问题。如果还有其他

PS K:\download\laifeng> pip install mysql
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple 
Collecting mysql
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9a/52/8d29c58f6ae448a72fbc612955bd31accb930ca479a7ba 
7197f4ae4edec2/mysql-0.0.3-py3-none-any.whl (1.2 kB)
Collecting mysqlclient
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/50/5f/eac919b88b9df39bbe4a855f136d58f80d191cfea34a3d 
cf96bf5d8ace0a/mysqlclient-2.1.1.tar.gz (88 kB)
     ---------------------------------------- 88.1/88.1 kB 828.7 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-37
      creating build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\_exceptions.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\connections.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\converters.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\cursors.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\release.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\times.py -> build\lib.win-amd64-cpython-37\MySQLdb
      creating build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CR.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\ER.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build\temp.win-amd64-cpython-37
      creating build\temp.win-amd64-cpython-37\Release
      creating build\temp.win-amd64-cpython-37\Release\MySQLdb
      "i:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x6
4\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 "-IC:\Prog
ram Files\MariaDB\MariaDB Connector C\include\mariadb" "-IC:\Program Files\MariaDB\MariaDB Connector C\includ
e" -IK:\ProgramData\Anaconda3\envs\py37\include -IK:\ProgramData\Anaconda3\envs\py37\Include "-Ii:\Program Fi
les (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-Ii:\Program File
s (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\W
indows Kits\NETFXSDK\4.6.1\include\um" "-II:\Windows Kits\10\include\10.0.17763.0\ucrt" "-II:\Windows Kits\10
\include\10.0.17763.0\shared" "-II:\Windows Kits\10\include\10.0.17763.0\um" "-II:\Windows Kits\10\include\10
.0.17763.0\winrt" "-II:\Windows Kits\10\include\10.0.17763.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win-
amd64-cpython-37\Release\MySQLdb/_mysql.obj
      _mysql.c
      MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory
      error: command 'i:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.
16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient, mysql
  Running setup.py install for mysqlclient ... error
  error: subprocess-exited-with-error

  × Running setup.py install for mysqlclient did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      running install
      K:\ProgramData\Anaconda3\envs\py37\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprec
ationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        setuptools.SetuptoolsDeprecationWarning,
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-37
      creating build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\_exceptions.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\connections.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\converters.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\cursors.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\release.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\times.py -> build\lib.win-amd64-cpython-37\MySQLdb
      creating build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CR.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\ER.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build\temp.win-amd64-cpython-37
      creating build\temp.win-amd64-cpython-37\Release
      creating build\temp.win-amd64-cpython-37\Release\MySQLdb
      "i:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x6
4\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 "-IC:\Prog
ram Files\MariaDB\MariaDB Connector C\include\mariadb" "-IC:\Program Files\MariaDB\MariaDB Connector C\includ
e" -IK:\ProgramData\Anaconda3\envs\py37\include -IK:\ProgramData\Anaconda3\envs\py37\Include "-Ii:\Program Fi
les (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-Ii:\Program File
s (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\W
indows Kits\NETFXSDK\4.6.1\include\um" "-II:\Windows Kits\10\include\10.0.17763.0\ucrt" "-II:\Windows Kits\10
\include\10.0.17763.0\shared" "-II:\Windows Kits\10\include\10.0.17763.0\um" "-II:\Windows Kits\10\include\10
.0.17763.0\winrt" "-II:\Windows Kits\10\include\10.0.17763.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win-
amd64-cpython-37\Release\MySQLdb/_mysql.obj
      _mysql.c
      MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory
      error: command 'i:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.
16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> mysqlclient

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
PS K:\download\laifeng>
PS K:\download\laifeng> pip install mysqlclient
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple 
Collecting mysqlclient
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/50/5f/eac919b88b9df39bbe4a855f136d58f80d191cfea34a3 
dcf96bf5d8ace0a/mysqlclient-2.1.1.tar.gz (88 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-37
      creating build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\_exceptions.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\connections.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\converters.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\cursors.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\release.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\times.py -> build\lib.win-amd64-cpython-37\MySQLdb
      creating build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CR.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\ER.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build\temp.win-amd64-cpython-37
      creating build\temp.win-amd64-cpython-37\Release
      creating build\temp.win-amd64-cpython-37\Release\MySQLdb
      "i:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x6
4\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 "-IC:\Prog
ram Files\MariaDB\MariaDB Connector C\include\mariadb" "-IC:\Program Files\MariaDB\MariaDB Connector C\includ
e" -IK:\ProgramData\Anaconda3\envs\py37\include -IK:\ProgramData\Anaconda3\envs\py37\Include "-Ii:\Program Fi
les (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-Ii:\Program File
s (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\W
indows Kits\NETFXSDK\4.6.1\include\um" "-II:\Windows Kits\10\include\10.0.17763.0\ucrt" "-II:\Windows Kits\10
\include\10.0.17763.0\shared" "-II:\Windows Kits\10\include\10.0.17763.0\um" "-II:\Windows Kits\10\include\10
.0.17763.0\winrt" "-II:\Windows Kits\10\include\10.0.17763.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win-
amd64-cpython-37\Release\MySQLdb/_mysql.obj
      _mysql.c
      MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory
      error: command 'i:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.
16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: 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
  error: subprocess-exited-with-error

  × Running setup.py install for mysqlclient did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      running install
      K:\ProgramData\Anaconda3\envs\py37\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprec
ationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        setuptools.SetuptoolsDeprecationWarning,
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-37
      creating build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\_exceptions.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\connections.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\converters.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\cursors.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\release.py -> build\lib.win-amd64-cpython-37\MySQLdb
      copying MySQLdb\times.py -> build\lib.win-amd64-cpython-37\MySQLdb
      creating build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\CR.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\ER.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-cpython-37\MySQLdb\constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build\temp.win-amd64-cpython-37
      creating build\temp.win-amd64-cpython-37\Release
      creating build\temp.win-amd64-cpython-37\Release\MySQLdb
      "i:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x6
4\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 "-IC:\Prog
ram Files\MariaDB\MariaDB Connector C\include\mariadb" "-IC:\Program Files\MariaDB\MariaDB Connector C\includ
e" -IK:\ProgramData\Anaconda3\envs\py37\include -IK:\ProgramData\Anaconda3\envs\py37\Include "-Ii:\Program Fi
les (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-Ii:\Program File
s (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\W
indows Kits\NETFXSDK\4.6.1\include\um" "-II:\Windows Kits\10\include\10.0.17763.0\ucrt" "-II:\Windows Kits\10
\include\10.0.17763.0\shared" "-II:\Windows Kits\10\include\10.0.17763.0\um" "-II:\Windows Kits\10\include\10
.0.17763.0\winrt" "-II:\Windows Kits\10\include\10.0.17763.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win-
amd64-cpython-37\Release\MySQLdb/_mysql.obj
      _mysql.c
      MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory
      error: command 'i:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.
16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> mysqlclient

问题,欢迎继续提问。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值