"Fatal Error: Python. H: No Such File or Directory" When Compiling Python File to a C Executable File?

I am trying to compile c from python.

There shows the following errors after I executing the following commands:

-Wall -I/usr/include/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5m.a -lpython35 -o prime_numbers_2 prime_numbers_2.c

prime_numbers_2.c:11:20: fatal error: Python.h: No Such File or
directory compilation terminated.

I also search in the directory /usr/lib with the following command:

find . -name Python.h

but there is no Python.h in that directory.

How can I fix these problems? Should I reinstall Python3.5.2?

2 Answers

You should install the development package of Python which contains header files and the library of Python.

sudo apt-get install python3-dev

Sources:

4

For those people who came here and are using pypy, make sure to do:

sudo apt-get install pypy3-dev

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest