[Python]pip安装mysqliclient报错 fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory

pip安装mysqliclient报错 fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory

出现这个错误的原因是本地没有配置mysql-connector-c的path,也就是说mysqlclient依赖的头文件是lib库没有找到。
注意:我本地安装的是visual studio 2019
[Python]pip安装mysqliclient报错 fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory_第1张图片

  1. 下载mysql-connector的c语言api
    下载地址:https://downloads.mysql.com/archives/c-c/
    [Python]pip安装mysqliclient报错 fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory_第2张图片
    我下载的是Windows (x86, 64-bit), ZIP Archive版,如果下载MSI Installer安装版,可以直接安装以省去下面的步骤。
  2. 解压缩后把include的所有头文件复制到Visual studio的MSVC编译器的include中
    [Python]pip安装mysqliclient报错 fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory_第3张图片
  3. mysqlclient.lib更名为mariadbclient.lib,然后把mariadbclient.lib复制到MSVC的lib中(由于我的是64bit,因此我放在x64中)
    需要注意自己的路径
    [Python]pip安装mysqliclient报错 fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory_第4张图片
  4. 安装mysqlclient
pip install -U mysqlclient

[Python]pip安装mysqliclient报错 fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory_第5张图片
Successfully!!!

你可能感兴趣的:(Oh,Notes,#,Today's,Python,mysql,python,pip,mysqlclient)