Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc cant find Python.h

As the title says, Im trying to install netifaces library in Fedora Distribution, using pip3 install netifaces and I keep getting the following error.

        1 | #include <Python.h>
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

I search for Python.h using locate Python.h and found it at /usr/include/python2.7/Python.h.

Next step, I tried installing dnf install python-dev (no package is found) then tried dnf install python3.8-dev.

But this does not solve my problem at all, I still can not install netifaces library because gcc can't find Python.h (which I have an older version of 2.7)

Here is the full output when I run pip3 install netifaces:

Defaulting to user installation because normal site-packages is not writeable
Collecting netifaces
  Downloading netifaces-0.10.9.tar.gz (28 kB)
Using legacy 'setup.py install' for netifaces, since package 'wheel' is not installed.
Installing collected packages: netifaces
    Running setup.py install for netifaces ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-743bfly4/netifaces/setup.py'"'"'; __file__='"'"'/tmp/pip-install-743bfly4/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-panq4br6/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ablil/.local/include/python3.8/netifaces                                             
         cwd: /tmp/pip-install-743bfly4/netifaces/                                                  
    Complete output (20 lines):                                                                     
    running install                                                                                 
    running build                                                                                   
    running build_ext                                                                               
    checking for getifaddrs...found.                                                                
    checking for getnameinfo...found.                                                               
    checking for IPv6 socket IOCTLs...not found.                                                    
    checking for optional header files...netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h netrose/rose.h linux/atm.h linux/llc.h linux/tipc.h linux/dn.h.       
    checking whether struct sockaddr has a length field...no.                                       
    checking which sockaddr_xxx structs are defined...at ax25 in in6 ipx un rose ash ec ll atmpvc atmsvc dn llc.                                                                                        
    checking for routing socket support...no.                                                       
    checking for sysctl(CTL_NET...) support...no.                                                   
    checking for netlink support...yes.                                                             
    will use netlink to read routing table                                                          
    building 'netifaces' extension                                                                  
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DNETIFACES_VERSION=0.10.9 -DHAVE_GETIFADDRS=1 -DHAVE_GETNAMEINFO=1 -DHAVE_NETASH_ASH_H=1 -DHAVE_NETATALK_AT_H=1 -DHAVE_NETAX25_AX25_H=1 -DHAVE_NETECONET_EC_H=1 -DHAVE_NETIPX_IPX_H=1 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_NETROSE_ROSE_H=1 -DHAVE_LINUX_ATM_H=1 -DHAVE_LINUX_LLC_H=1 -DHAVE_LINUX_TIPC_H=1 -DHAVE_LINUX_DN_H=1 -DHAVE_SOCKADDR_AT=1 -DHAVE_SOCKADDR_AX25=1 -DHAVE_SOCKADDR_IN=1 -DHAVE_SOCKADDR_IN6=1 -DHAVE_SOCKADDR_IPX=1 -DHAVE_SOCKADDR_UN=1 -DHAVE_SOCKADDR_ROSE=1 -DHAVE_SOCKADDR_ASH=1 -DHAVE_SOCKADDR_EC=1 -DHAVE_SOCKADDR_LL=1 -DHAVE_SOCKADDR_ATMPVC=1 -DHAVE_SOCKADDR_ATMSVC=1 -DHAVE_SOCKADDR_DN=1 -DHAVE_SOCKADDR_LLC=1 -DHAVE_PF_NETLINK=1 -I/usr/include/python3.8 -c netifaces.c -o build/temp.linux-x86_64-3.8/netifaces.o
    netifaces.c:1:10: fatal error: Python.h: No such file or directory
        1 | #include <Python.h>
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-743bfly4/netifaces/setup.py'"'"'; __file__='"'"'/tmp/pip-install-743bfly4/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-panq4br6/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ablil/.local/include/python3.8/netifaces Check the logs for full command output.
like image 833
whatspoppin Avatar asked Jun 15 '26 17:06

whatspoppin


1 Answers

Solution

sudo dnf install python3-devel

ps: all credit goes to Venky. I just added the answer for more clarity. OP please add this ass accepted answer.

like image 87
Slim Aloui Avatar answered Jun 18 '26 07:06

Slim Aloui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!