1 pip安装mysqlclient失败 2天01时28分38秒

发布于 2025-07-24 16:16:20

我在启动后端项目,使用pip3 install -r requirements.txt安装mysqlclient一直失败,根据ai的说法,我可以安装mysql-connector-c或者使用预编译的mysqlclient‑2.2.0‑cp312‑cp312‑win_amd64.whl,但是我在网络上根本找不到这个预编译的文件,我安装好mysql-connector-c还是报错,报错信息如下:
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for mysqlclient (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [81 lines of output]

  C:\Users\zqx\AppData\Local\Temp\pip-build-env-ef7qr_a4\overlay\Lib\site-packages\setuptools\config\_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated
  !!

          ********************************************************************************
          Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0).

          By 2026-Feb-18, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.

          See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
          ********************************************************************************

  !!
    corresp(dist, value, root_dir)
  C:\Users\zqx\AppData\Local\Temp\pip-build-env-ef7qr_a4\overlay\Lib\site-packages\setuptools\config\_apply_pyprojecttoml.py:61: SetuptoolsDeprecationWarning: License classifiers are deprecated.
  !!

          ********************************************************************************
          Please consider removing the following classifiers in favor of a SPDX license expression:

          License :: OSI Approved :: GNU General Public License (GPL)

          See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
          ********************************************************************************

  !!
    dist._finalize_license_expression()
  C:\Users\zqx\AppData\Local\Temp\pip-build-env-ef7qr_a4\overlay\Lib\site-packages\setuptools\dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
  !!

          ********************************************************************************
          Please consider removing the following classifiers in favor of a SPDX license expression:

          License :: OSI Approved :: GNU General Public License (GPL)

          See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
          ********************************************************************************

  !!
    self._finalize_license_expression()
  # Options for building extention module:
    library_dirs: ['C:/mariadb-connector\\lib\\mariadb', 'C:/mariadb-connector\\lib']
    libraries: ['kernel32', 'advapi32', 'wsock32', 'shlwapi', 'Ws2_32', 'crypt32', 'secur32', 'bcrypt', 'mariadbclient']
    extra_link_args: ['/MANIFEST']
    include_dirs: ['C:/mariadb-connector\\include\\mariadb', 'C:/mariadb-connector\\include']
    extra_objects: []
    define_macros: [('version_info', (2, 2, 0, 'final', 0)), ('__version__', '2.2.0')]
  running bdist_wheel
  running build
  running build_py
  creating build\lib.win-amd64-cpython-312\MySQLdb
  copying src\MySQLdb\connections.py -> build\lib.win-amd64-cpython-312\MySQLdb
  copying src\MySQLdb\converters.py -> build\lib.win-amd64-cpython-312\MySQLdb
  copying src\MySQLdb\cursors.py -> build\lib.win-amd64-cpython-312\MySQLdb
  copying src\MySQLdb\release.py -> build\lib.win-amd64-cpython-312\MySQLdb
  copying src\MySQLdb\times.py -> build\lib.win-amd64-cpython-312\MySQLdb
  copying src\MySQLdb\_exceptions.py -> build\lib.win-amd64-cpython-312\MySQLdb
  copying src\MySQLdb\__init__.py -> build\lib.win-amd64-cpython-312\MySQLdb
  creating build\lib.win-amd64-cpython-312\MySQLdb\constants
  copying src\MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
  copying src\MySQLdb\constants\CR.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
  copying src\MySQLdb\constants\ER.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
  copying src\MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
  copying src\MySQLdb\constants\FLAG.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
  copying src\MySQLdb\constants\__init__.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
  running egg_info
  writing src\mysqlclient.egg-info\PKG-INFO
  writing dependency_links to src\mysqlclient.egg-info\dependency_links.txt
  writing top-level names to src\mysqlclient.egg-info\top_level.txt
  reading manifest file 'src\mysqlclient.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  adding license file 'LICENSE'
  writing manifest file 'src\mysqlclient.egg-info\SOURCES.txt'
  copying src\MySQLdb\_mysql.c -> build\lib.win-amd64-cpython-312\MySQLdb
  running build_ext
  building 'MySQLdb._mysql' extension
  creating build\temp.win-amd64-cpython-312\Release\src\MySQLdb
  "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-Dversion_info=(2, 2, 0, 'final', 0)" -D__version__=2.2.0 -IC:/mariadb-connector\include\mariadb -IC:/mariadb-connector\include -IC:\ProgramData\anaconda3\include -IC:\ProgramData\anaconda3\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.26100.0\\cppwinrt" /Tcsrc/MySQLdb/_mysql.c /Fobuild\temp.win-amd64-cpython-312\Release\src\MySQLdb\_mysql.obj
  _mysql.c
  src/MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.44.35207\\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
Failed to build mysqlclient
ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)

查看更多

关注者
0
被浏览
34
0 个回答
暂无答案,快来添加答案吧

撰写答案 当前问题悬赏金额为¥1 元,被提问者采纳后将获得赏金

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览