Fatal error python h no such file or directory linux

Решение проблемы с ошибкой «fatal error: Python.h: Нет такого файла или каталога»

Если при компиляции программы вы получаете ошибку, что отсутствует файл Python.h, то необходимо установить дополнительный пакет.

Вам нужно обратить внимание, какая версия Python используется для компиляции программы: 2.x или 3.x. Файлы заголовков помещены в различные пакеты для этих версий, поэтому вам нужно установить правильный пакет, в соответствии с используемой при компиляции версией Python. В большинстве популярных дистрибутивов требуемый пакет имеется в стандартном репозитории, поэтому установка выполняется в одну команду.

Текст ошибки может чуть различаться, в зависимости от того, в каком файле она возникла. Примеры сообщений:

Самой вероятной причиной этого является то, что не установлены файлы заголовка и статичных библиотек для python dev. Для установки их на системном уровне используйте менеджер пакетов для вашего дистрибутива.

Для apt (Ubuntu, Debian, Kali Linux, Linux Mint…):

Если программа компилируется для python2.x, то выполните команду:

Если программа компилируется для python3.x, то выполните команду:

Для yum (CentOS, RHEL…):

Если вам нужно установить для других версий Python, то замените цифры на нужные, например:

Для dnf (Fedora…):

Для zypper (openSUSE…):

Если после установки заголовков проблема не исчезла, то возможно, что вы выбрали неверную версию Python.

Источник

Debian / Ubuntu: Fatal error: Python.h: No such file or Directory

gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c -o build/temp.linux-x86_64-2.7/src/MD2.o

src/MD2.c:31:20: fatal error: Python.h: No such file or directory

error: command ‘gcc’ failed with exit status 1

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements None
Est. reading time N/A

Where can I find Python.h file and how do I fix this problem under Debian or Ubuntu Linux sever based system?

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications. To install this package, enter:

For Python version 2.x+

$ sudo apt-get install python-dev
OR
# apt-get install python-dev

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

For Python version 3.x+

$ sudo apt-get install python3-dev
OR
# apt-get install python3-dev
Sample outputs (for my python 2.x):

Now, you can compile or build any python based modules.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

Thanks for this! Also I had to

To get it to work again – because the previous results had been cached!

That saved me 🙂 Thanks!

In my case (building pyskein) I needed the python3-dev package.

Thanks for the tip on the python3 bit. I was running the command listed on and linux was telling me everything was up to date.

Tnx for your post

Thank you.
Really helped me. 😀

For Fedora it is:

yum install python-devel

Does not work for me. I get the error “no installation candidate”.

thank you for help

I have installed python-dev but still..
fatal error: Python.h: No such file or directory
compilation terminated.

Are you using Python3? If so, you have to install python3-dev package.

Yeah you have to use python3-dev

sudo apt-get install python3-dev

src/main/Session.cpp:21:25: fatal error: cms/Session.h: No such file or directory
compilation terminated.
error: command ‘gcc’ failed with exit status 1…
while python setup.py build

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DBOOST_PYTHON_NO_PY_SIGNATURES=1 -DPYACTIVEMQ_ENABLE_DOCSTRINGS=0 -Ipython_activemq_libs/activemq-cpp-cppVersion/include/activemq-cpp-cppVersion -I/usr/include/python2.7 -c src/main/Session.cpp -o build/temp.linux-x86_64-2.7/src/main/Session.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
src/main/Session.cpp:21:25: fatal error: cms/Session.h: No such file or directory
compilation terminated.
error: command ‘gcc’ failed with exit status 1

hi i used the following code and got the result as follows
$ gcc -c arith.c arith_wrap.c \-I/usr/local/include/python2.7
arith_wrap.c:125:20: fatal error: Python.h: No such file or directory
compilation terminated.
ttl@ttl-HP-Z220-CMT-Workstation:

i did sudo apt-get to install python 2.7 and it showed my library is updated.. the error repeats.. please give some suggestion…

Gracias, me funciuono a la primera

sudo apt-get install python2.7-dev

Thenk you, second time this post help for me 🙂

Источник

fatal error :»python.h» no file or directory?

While looking for a solution for the Hungarian problem, I found this GitHub link.

I went through the readme.md file and I performed everything described there. After copying hungarian.so into my working directory, when I tried to compile hungarian.cpp using make hungarian , I got this output:

I found this related question on Stack Overflow, but the answer didn’t work for me.

I am very new to GitHub I don’t know how to add modules on g++ . Can someone help me with that, and what to do next?

3 Answers 3

For Ubuntu 15.10 and Python 3:

So install the following packages:

To identify the missing packages (the ones providing the headers), look at packages.ubuntu.com.

/Python/hungarian-master$ dpkg -L python-dev | grep Python.h anupam@JAZZ:

/Python/hungarian-master$ how can I resolve it??

This is python code extending with C. No need to use make . Python itself will take care of the cpp code compilation with proper flags.

First you need to have header files and a static library. Install those as,

Now follow these commands to execute example.py in your code.

Note: I am using python2.7 , you should take care of your version of python when execute the above commands. It is worth mentioning that you need to install python-numpy if you not have it as python script need it.

Источник

cpyrit/_cpyrit_cpu.c:32:10: fatal error: Python.h: No such file or directory #598

Comments

MrHim commented Apr 14, 2020

: /Pyrit$ python setup.py build
running build
running build_py
running build_ext
building ‘cpyrit._cpyrit_cpu’ extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/cpyrit
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IzSqQI/python2.7-2.7.18 rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c cpyrit/_cpyrit_cpu.c -o build/temp.linux-x86_64-2.7/cpyrit/_cpyrit_cpu.o -Wall -fno-strict-aliasing -DVERSION=»0.5.1″ -maes -mpclmul
cpyrit/_cpyrit_cpu.c:32:10: fatal error: Python.h: No such file or directory
32 | #include

compilation terminated.
Failed to build; Compiling without AES-NI
building ‘cpyrit._cpyrit_cpu’ extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-IzSqQI/python2.7-2.7.18

rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c cpyrit/_cpyrit_cpu.c -o build/temp.linux-x86_64-2.7/cpyrit/_cpyrit_cpu.o -Wall -fno-strict-aliasing -DVERSION=»0.5.1″
cpyrit/_cpyrit_cpu.c:32:10: fatal error: Python.h: No such file or directory
32 | #include

compilation terminated.
error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1

The text was updated successfully, but these errors were encountered:

Источник

Installation error: «netifaces.c:1:20: fatal error: Python.h: No such file or directory» #20

Comments

User2020 commented Nov 15, 2014

Hi. Please forgive me if I am doing this wrong. this is my first GitHub entry.

I was so excited to see your work. Thank you for sharing it. But I am having an issue installing it on my Pi. I am running Raspian and it is pretty much a fresh install. Things were going well for awhile until I hit the following (including as much info as possible for you — see the end for the error).

Please let me know if I can provide any more info or if I should go about this a different way. Noob here but picking things up fast 🙂 Thanks a lot.

(I followed the directions exactly. I also tried the steps under «The right way to use an under-development python project makes use of virtualenv and virtualenvwrapper utilities» but got the same error during setup.)

Downloading/unpacking https://github.com/diraimondo/gmusicproxy/tarball/master
Downloading master (unknown size): 25Kb downloaded
Running setup.py egg_info for package from https://github.com/diraimondo/gmusi cproxy/tarball/master

Downloading/unpacking gmusicapi>=4.0.0 (from gmusicproxy==0.9.8)
Downloading gmusicapi-4.0.0.tar.gz (144Kb): 144Kb downloaded
Running setup.py egg_info for package gmusicapi

Downloading/unpacking netifaces (from gmusicproxy==0.9.8)
Downloading netifaces-0.10.4.tar.gz
Running setup.py egg_info for package netifaces

Downloading/unpacking pyxdg (from gmusicproxy==0.9.8)
Downloading pyxdg-0.25.tar.gz (48Kb): 48Kb downloaded
Running setup.py egg_info for package pyxdg

Downloading/unpacking eyed3 (from gmusicproxy==0.9.8)
Downloading eyeD3-0.7.5.tgz (221Kb): 221Kb downloaded
Running setup.py egg_info for package eyed3
warning: no previously-included files matching ‘*’ found under directory ‘do cs/_build’
Downloading/unpacking python-daemon (from gmusicproxy==0.9.8)
Downloading python-daemon-1.6.1.tar.gz (47Kb): 47Kb downloaded
Running setup.py egg_info for package python-daemon

Downloading/unpacking validictory>=0.8.0,!=0.9.2 (from gmusicapi>=4.0.0->gmusicp roxy==0.9.8)
Downloading validictory-1.0.0a2.tar.gz
Running setup.py egg_info for package validictory

Downloading/unpacking decorator>=3.3.1 (from gmusicapi>=4.0.0->gmusicproxy==0.9. 8)
Downloading decorator-3.4.0.tar.gz
Running setup.py egg_info for package decorator

Downloading/unpacking mutagen>=1.18 (from gmusicapi>=4.0.0->gmusicproxy==0.9.8)
Downloading mutagen-1.26.tar.gz (868Kb): 868Kb downloaded
Running setup.py egg_info for package mutagen

Downloading/unpacking protobuf>=2.4.1 (from gmusicapi>=4.0.0->gmusicproxy==0.9.8 )
Downloading protobuf-2.6.1.tar.gz (188Kb): 188Kb downloaded
Running setup.py egg_info for package protobuf

Downloading/unpacking requests>=1.1.0,!=1.2.0,!=2.2.1 (from gmusicapi>=4.0.0->gm usicproxy==0.9.8)
Downloading requests-2.4.3.tar.gz (438Kb): 438Kb downloaded
Running setup.py egg_info for package requests

Downloading/unpacking python-dateutil>=1.3,!=2.0 (from gmusicapi>=4.0.0->gmusicp roxy==0.9.8)
Downloading python-dateutil-2.2.tar.gz (259Kb): 259Kb downloaded
Running setup.py egg_info for package python-dateutil

Downloading/unpacking proboscis>=1.2.5.1 (from gmusicapi>=4.0.0->gmusicproxy==0. 9.8)
Downloading proboscis-1.2.6.0.tar.gz
Running setup.py egg_info for package proboscis

Downloading/unpacking oauth2client>=1.1 (from gmusicapi>=4.0.0->gmusicproxy==0.9 .8)
Downloading oauth2client-1.4.1.tar.gz (44Kb): 44Kb downloaded
Running setup.py egg_info for package oauth2client

Downloading/unpacking mock>=0.7.0 (from gmusicapi>=4.0.0->gmusicproxy==0.9.8)
Downloading mock-1.0.1.tar.gz (818Kb): 818Kb downloaded
Running setup.py egg_info for package mock

Downloading/unpacking appdirs>=1.1.0 (from gmusicapi>=4.0.0->gmusicproxy==0.9.8)
Downloading appdirs-1.4.0.tar.gz
Running setup.py egg_info for package appdirs

Downloading/unpacking python-magic (from eyed3->gmusicproxy==0.9.8)
Downloading python-magic-0.4.6.tar.gz
Running setup.py egg_info for package python-magic

Requirement already satisfied (use —upgrade to upgrade): distribute in /usr/lib /python2.7/dist-packages (from python-daemon->gmusicproxy==0.9.8)
Downloading/unpacking lockfile>=0.9 (from python-daemon->gmusicproxy==0.9.8)
Downloading lockfile-0.10.2.tar.gz
Running setup.py egg_info for package lockfile

Downloading/unpacking six (from python-dateutil>=1.3,!=2.0->gmusicapi>=4.0.0->gm usicproxy==0.9.8)
Downloading six-1.8.0.tar.gz
Running setup.py egg_info for package six

Downloading/unpacking httplib2>=0.8 (from oauth2client>=1.1->gmusicapi>=4.0.0->g musicproxy==0.9.8)
Downloading httplib2-0.9.tar.gz (204Kb): 204Kb downloaded
Running setup.py egg_info for package httplib2

Downloading/unpacking pyasn1==0.1.7 (from oauth2client>=1.1->gmusicapi>=4.0.0->g musicproxy==0.9.8)
Downloading pyasn1-0.1.7.tar.gz (68Kb): 68Kb downloaded
Running setup.py egg_info for package pyasn1

Downloading/unpacking pyasn1-modules==0.0.5 (from oauth2client>=1.1->gmusicapi>= 4.0.0->gmusicproxy==0.9.8)
Downloading pyasn1-modules-0.0.5.tar.gz
Running setup.py egg_info for package pyasn1-modules

Downloading/unpacking rsa==3.1.4 (from oauth2client>=1.1->gmusicapi>=4.0.0->gmus icproxy==0.9.8)
Downloading rsa-3.1.4.tar.gz
Running setup.py egg_info for package rsa

Installing collected packages: gmusicapi, netifaces, pyxdg, eyed3, python-daemon , gmusicproxy, validictory, decorator, mutagen, protobuf, requests, python-dateu til, proboscis, oauth2client, mock, appdirs, python-magic, lockfile, six, httpli b2, pyasn1, pyasn1-modules, rsa
Running setup.py install for gmusicapi

Running setup.py install for netifaces
checking for getifaddrs. found.
checking for getnameinfo. found.
checking for optional header files. netash/ash.h netatalk/at.h netax25/ax25 .h neteconet/ec.h netipx/ipx.h netpacket/packet.h linux/irda.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 ash ec ll atmpvc atmsvc dn irda 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 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-pro totypes -fPIC -DNETIFACES_VERSION=0.10.4 -DHAVE_GETIFADDRS=1 -DHAVE_GETNAMEINFO= 1 -DHAVE_NETASH_ASH_H=1 -DHAVE_NETATALK_AT_H=1 -DHAVE_NETAX25_AX25_H=1 -DHAVE_NE TECONET_EC_H=1 -DHAVE_NETIPX_IPX_H=1 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_LINUX_IR DA_H=1 -DHAVE_LINUX_ATM_H=1 -DHAVE_LINUX_LLC_H=1 -DHAVE_LINUX_TIPC_H=1 -DHAVE_LI NUX_DN_H=1 -DHAVE_SOCKADDR_AT=1 -DHAVE_SOCKADDR_AX25=1 -DHAVE_SOCKADDR_IN=1 -DHA VE_SOCKADDR_IN6=1 -DHAVE_SOCKADDR_IPX=1 -DHAVE_SOCKADDR_UN=1 -DHAVE_SOCKADDR_ASH =1 -DHAVE_SOCKADDR_EC=1 -DHAVE_SOCKADDR_LL=1 -DHAVE_SOCKADDR_ATMPVC=1 -DHAVE_SOC KADDR_ATMSVC=1 -DHAVE_SOCKADDR_DN=1 -DHAVE_SOCKADDR_IRDA=1 -DHAVE_SOCKADDR_LLC=1 -DHAVE_PF_NETLINK=1 -I/usr/include/python2.7 -c netifaces.c -o build/temp.linux -armv6l-2.7/netifaces.o
netifaces.c:1:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command ‘gcc’ failed with exit status 1
Complete output from command /usr/bin/python -c «import setuptools;file= ‘/home/pi/build/netifaces/setup.py’;exec(compile(open(file).read().replace(‘ \r\n’, ‘\n’), file, ‘exec’))» install —single-version-externally-managed — record /tmp/pip-qjitpo-record/install-record.txt:
running install

checking for getifaddrs. found.

checking for getnameinfo. found.

checking for optional header files. netash/ash.h netatalk/at.h netax25/ax25.h n eteconet/ec.h netipx/ipx.h netpacket/packet.h linux/irda.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 ash ec l l atmpvc atmsvc dn irda 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 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototy pes -fPIC -DNETIFACES_VERSION=0.10.4 -DHAVE_GETIFADDRS=1 -DHAVE_GETNAMEINFO=1 -D HAVE_NETASH_ASH_H=1 -DHAVE_NETATALK_AT_H=1 -DHAVE_NETAX25_AX25_H=1 -DHAVE_NETECO NET_EC_H=1 -DHAVE_NETIPX_IPX_H=1 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_LINUX_IRDA_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_S OCKADDR_IN6=1 -DHAVE_SOCKADDR_IPX=1 -DHAVE_SOCKADDR_UN=1 -DHAVE_SOCKADDR_ASH=1 — DHAVE_SOCKADDR_EC=1 -DHAVE_SOCKADDR_LL=1 -DHAVE_SOCKADDR_ATMPVC=1 -DHAVE_SOCKADD R_ATMSVC=1 -DHAVE_SOCKADDR_DN=1 -DHAVE_SOCKADDR_IRDA=1 -DHAVE_SOCKADDR_LLC=1 -DH AVE_PF_NETLINK=1 -I/usr/include/python2.7 -c netifaces.c -o build/temp.linux-arm v6l-2.7/netifaces.o

netifaces.c:1:20: fatal error: Python.h: No such file or directory

error: command ‘gcc’ failed with exit status 1

Command /usr/bin/python -c «import setuptools;file=’/home/pi/build/netifaces /setup.py’;exec(compile(open(file).read().replace(‘\r\n’, ‘\n’), file, ‘ exec’))» install —single-version-externally-managed —record /tmp/pip-qjitpo-re cord/install-record.txt failed with error code 1 in /home/pi/build/netifaces
Storing complete log in /root/.pip/pip.log

The text was updated successfully, but these errors were encountered:

Источник

Читайте также:  Запуск языковая панель windows
Оцените статью