Python报错:error: command ‘/usr/bin/gcc‘ failed with exit code 1

时间:2025-04-14 19:31:41

前言

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

...
#include ""
           ^~~~~~~~~~
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  installs
sudo apt-get install python3-dev  # for  installs

参考链接

fatal error: : No such file or directory