pip3 安装 mysqlclient 的时候,出现报错 _mysql.c:32:20: fatal error: Python.h: No such file or directory

pip3 install mysqlclient==1.3.12

报错内容

  _mysql.c:32:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

Linux学习32 - _mysql.c:32:20: fatal error: Python.h: No such file or directory 问题解决

解决思路

刚开始看到command 'gcc' failed还以为是缺少gcc编译包,于是yum安装gcc相关

yum install gcc gcc-c++ kernel-devel

安装完成后依然报错,于是搜索:_mysql.c:32:20: fatal error: Python.h: No such file or directory 发现是缺少 python3-devel
centos 系统

  • python2版本执行:sudo yum install python-devel
  • python3版本执行:sudo yum install python3-devel

Ubuntu,Debian系统

  • python2版本执行:sudo apt-get install python-dev
  • python3版本执行:sudo apt-get install python3-dev

安装 python3-devel 依赖后,重新执行就解决了

相关文章:

  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-12-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-14
  • 2022-12-23
相关资源
相似解决方案