pip install mysqlclient with Python 3.8 不起作用

Rux*_*ima 5 python mysql django pip

我有一个使用 Python 3.8 的 django 项目,我尝试通过以下命令安装mysqlclient库:pip install mysqlclient我收到这个错误:

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
Run Code Online (Sandbox Code Playgroud)
  1. 我尝试使用来自何处的轮子文件进行安装(我尝试了此站点上的每个轮子),但出现错误:*...is not a supported wheel on this platform.*
  2. 我尝试从源代码安装它,但是当我运行此命令时python setup.py install,出现相同的错误:
  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
Run Code Online (Sandbox Code Playgroud)
  1. 我尝试了这个命令pip install --only-binary :all: mysqlclient,但收到错误:

    无法找到满足 mysqlclient 要求的版本(来自版本:)未找到 mysqlclient 的匹配发行版

    如果您有任何建议,请告诉我。谢谢你!

Fly*_*ler 0

Cannot open include file: 'mysql.h': No such file or directory

从源代码编译时,您缺少mysql所需的库mysqlclient

此平台不支持滚轮

我打赌你已经安装了 32 位 python。pypi 上的所有 whl 文件mysqlclient均适用于 amd64,这可以解释为什么您的设置没有受支持的版本。您可以通过以下方式检查:

  1. 检查你的安装路径,如果包含类似的内容python38-32,那么你肯定是32位版本
  2. 输入pythoncmd检查第一行。对于我(64 位 python),它包含字符串MSC v.1915 64 bit (AMD64)

您可以做的就是卸载 32 位版本并安装 64 位版本,毕竟这mysqlclient不会是 pypi 上没有可用的 32 位 whl 文件的最后一个工具,或者您可以从mysqlclient此处下载32 位 whl 文件