【问题标题】:gcc cannot find file even though it is on the include pathgcc 找不到文件,即使它在包含路径上
【发布时间】:2021-09-17 11:48:23
【问题描述】:

我正在尝试在 Scientific Linux 7.9、Python 版本 3.8 上安装本地 Python 包。该包包含 Cython,因此需要 Python 头文件来构建。它已安装并位于包含路径上,但 gcc 仍然声称它找不到它。这是权限问题吗?

$ python setup.py install
running install
...
building 'farm.rasters.water_fill' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 
-fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 
-mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include -O2 -g -pipe 
-Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 
-grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include 
-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 
-grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC 
-I/home/jon/.jenkins/workspace/Farmmap_revision_linux_py36/TOXENV/py38/venv/lib64/python3.8/site-packages/numpy/core/include 
-I/home/jon/.jenkins/workspace/Farmmap_revision_linux_py36/TOXENV/py38/venv/include 
-I/opt/rh/rh-python38/root/include/python3.8 -c farm/rasters/water_fill.c 
-o build/temp.linux-x86_64-3.8/farm/rasters/water_fill.o
farm/rasters/water_fill.c:19:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1

我已经安装了rh-python38-python-devel,其中包括标题,它们位于上面给出的-I 路径中。

$ ls -l /opt/rh/rh-python38/root/usr/include/python3.8/
...
-rw-r--r--. 1 root root  3615 Jun 28 11:08 Python.h

我只需要chown 这个目录吗?我不需要在已安装该软件包的其他机器上执行此操作。

【问题讨论】:

    标签: python gcc redhat


    【解决方案1】:

    我已经弄清楚了 - 虽然可执行文件 /usr/bin/python/bin/python 看起来相同,但其中只有一个具有相关的头文件。

    当我创建 venv 时使用

     $ /opt/rh/rh-python38/root/usr/bin/python3.8 -m venv venv
    

    我可以构建我的项目,但是当我创建 venv 时使用

     $ /opt/rh/rh-python38/root/bin/python3.8 -m venv venv
    

    我不能。

    当我尝试查找与第二个可执行文件关联的包含时,那里什么都没有。

     $ ls /opt/rh/rh-python38/root/include/python3.8
    ls: cannot access /opt/rh/rh-python38/root/include/python3.8: No such file or directory
    

    【讨论】:

      【解决方案2】:

      如果它没有显示路径并向您显示“找不到路径”错误。 只需尝试以管理员身份打开 Windows PowerShell 并键入命令 sfc /scannow 并等待几分钟,如果它会告诉您它发现 某些文件已损坏 或其他损坏的警告。然后你只需运行一个命令 Dism /Online /Cleanup-Image /RestoreHealth 并等待半小时,这需要时间并重新启动您的 PC,然后再次检查它是否正常工作。 希望它可以帮助你?。

      【讨论】:

      • 感谢您的建议,但正如上面所说,我使用的是 Linux...
      猜你喜欢
      • 2012-08-18
      • 2018-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-13
      • 2018-10-21
      • 1970-01-01
      相关资源
      最近更新 更多