致命错误:Python.h 没有这样的文件或目录 - 但 python-dev 已安装

esa*_*esa 5 python ubuntu mod-wsgi python-3.6

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

src/server/wsgi_python.h:24:10: fatal error: Python.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)

mod_wsgi故障排除部分和 SO(1、2、3)上的其他帖子表示安装正确版本的 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.
Run Code Online (Sandbox Code Playgroud)

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

$ locate Python.h
/usr/include/python3.6m/Python.h
Run Code Online (Sandbox Code Playgroud)

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

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

esa*_*esa 1

我运行./configure了 mod_wsgi 并看到了输出checking for python... /usr/bin/python。当我跑步时locate Python.h它给了我/usr/include/python3.6m/Python.h。所以看起来配置找到了错误的 python 版本。然后我./configure --with-python=/usr/bin/python3.6m按照mod_wsgi 文档的建议运行。现在运行make成功了。

我后来发现这是安装 mod_wsgi 更困难的方法。我最终只是遵循了这个 tecadmin 指南,其中说运行命令sudo apt-get install libapache2-mod-wsgi。这就是我所做的,mod_wsgi 现在正在与 apache 一起工作。