"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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like