gcc cannot find file even though it is on the include path

Viewed 127

I'm trying to install a local Python package on Scientific Linux 7.9, Python version 3.8. The package contains Cython so needs Python headers to build. This is installed and is on the include path, but gcc is still claiming it can't find it. Is this a permissions issue?

$ 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

I have installed rh-python38-python-devel, which includes the headers and they are in the -I path given above.

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

Do I just need to chown this directory? I haven't needed to do this on other machines I have installed the package on.

2 Answers

I have figured it out - while the executables /usr/bin/python and /bin/python appear to be the same, only one of them has the associated header files.

When I create a venv using

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

I can build my project, but when I create the venv with

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

I cannot.

When I try to look for the includes associated with the second executable, there is nothing there.

 $ 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

if it is not showing path and showing a you a "path not found" error. Simply try to open windows PowerShell as administrator and type a command sfc /scannow and wait for some minutes if it will show you that it found some files are corrupted or other corrupted warnings. then you simply run a command Dism /Online /Cleanup-Image /RestoreHealth and wait for half an hour, it takes time and restart your PC and then check again if it is working or not. Hope its Helps you .

Related