Debian/Ubuntu:致命错误:Python.h:无此类文件或目录

时间:2020-01-09 10:38:02  来源:igfitidea点击:

在尝试使用pip命令安装第三方python应用程序,出现以下错误:

**src/MD2.c:31:20: fatal error: Python.h: No such file or directory**

compilation terminated.

error: command 'gcc' failed with exit status 1

如何在基于Debian或Ubuntu Linux服务器的系统下解决此问题?

Python.h只是一个头文件。

gcc使用它来构建应用程序。
您需要安装一个名为python-dev的软件包。
该软件包包括头文件,静态库和用于构建Python模块,扩展Python解释器或将Python嵌入应用程序中的开发工具。
要安装此软件包,请输入:

对于Python版本2.x +

$ sudo apt-get install python-dev

或者

# apt-get install python-dev

对于Python版本3.x +

$ sudo apt-get install python3-dev

或者

# apt-get install python3-dev

现在,您可以编译或构建任何基于python的模块。