Net-informations.com

Fatal error: Python.h: No such file or directory

Python.h is used by GNU Compiler Collection (gcc) to build applications. You need to install a package called python-dev for building Python modules, extending the Python interpreter or embedding Python in applications. The python-dev package includes header files, a static library and development tools. You encounter "Python.h: No such file or directory" error while trying to build a shared library using the file extension of another language ( e.g. 'C' ). If you are trying to build a shared library using the file extension of another language, you need to install the correct development version of Python.

Reason for this error:

  1. You haven't properly installed the header files and static libraries for python dev.
  2. Also, sometimes include files might not be default in the include path.

How to solve this error:

  1. Install the missing files and libraries.
  2. Include Path and Library.
  3. Finally, Compile it.

Python.h: No such file or directory

Install the missing files and libraries

You must install the Python development files on your operating system if the Python provided with your operating system does not come with them. Use the following commands according to the OS installed on your system.

Ubuntu, Debian (apt)

CentOS, RHEL (yum)

Fedora (dnf)

openSUSE (zypper)

Alpine (apk)

Cygwin (apt-cyg)

Rasberry Pi (apt)

Include Path and Library

If you are not already include path and Library, use include files in the default include path and Python Library to be linked with executable.

Finally, Compile it

How to ensure the Python dev files come with your OS?

The pkg-config is a helper tool used when compiling applications and libraries. You can easily avoid this error by checking that the Python dev files come with your operating system. To avoid the fatal error, you should not hard code the library and include paths. The pkg-config helps you insert the correct compiler options on the command line so an application can use gcc -o test test.c 'pkg-config --libs --cflags glib-2.0'.

example

Also, add the following to the gcc line:










net-informations.com (C) 2022    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About