前言

平时我们在Linux服务器上使用pip安装一些Python依赖包的时候偶尔会遇到如下所示的报错:

...
#include "Python.h"
           ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
...

常见的如安装uWSGI和mysqlclient都会出现类似报错,那么遇到这种情况该怎么办呢?

解决方案

对于yum(CentOS, RHEL…)

yum install python39-devel

39为你安装的python版本

对于apt(Ubuntu, Debian…)

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs

参考链接

fatal error: Python.h: No such file or directory

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐