首页 > 解决方案 > 致命错误:Python.h 没有这样的文件或目录 - 但已经安装了 python-dev

问题描述

我正在尝试在 Ubuntu 上安装 mod_wsgi。当按照 mod_wsgi 网站上的描述运行“sudo make”命令时,我收到错误:

src/server/wsgi_python.h:24:10: fatal error: Python.h: No such file or directory

SO ( 1 , 2 , 3 ) 上的mod_wsgi 故障排除部分和其他帖子说要安装正确版本的 python-dev。这已经根据以下输出完成。Python3 运行 3.6.7 和 apt-get 说 python3-dev 是最新版本的 3.6.7。

$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 

$ sudo apt-get install python3-dev
...
python3-dev is already the newest version (3.6.7-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.

所以看起来 Python.h 文件在那里但make找不到它。我查看了这篇 SO 帖子(4),但我认为它不适用于我,因为我能够找到 Python.h。

$ locate Python.h
/usr/include/python3.6m/Python.h

我不确定下一步该去哪里。Python3.6-dev 已安装,我可以找到 Python.h,但make不能。我正在使用 Pycharm 自动为我创建的 venv,我有一种预感,它与问题有关,但我不确定如何跟进这种预感。我make在同一个终端上运行python3apt-get所以他们应该使用相同的环境变量(我的理解)。

有人对下一步有什么建议吗?

标签: pythonubuntupython-3.6mod-wsgi

解决方案


要添加到上面的答案(因为我很固执),我会注意到您必须python[3]-dev安装包(这是提供的包Python.h)。在 ubuntu 上,apt install python3-dev为我解决了这个问题。


推荐阅读