Python.h file not found on Ubuntu 20.04 even after installing python-dev

I just switched to Linux (Ubuntu 20.04) from Windows. After installing python-dev I notice that Python.h is still not included, which breaks my integrated Python-C++ build (I'm using pybind11). I also tried to install every other variant of python-dev I saw mentioned online (python3-dev, python-devel, etc.) but to no avail.

Interestingly, installing python3-dev on Ubuntu 18.04 includes this file and everything works.

Might this be a bug in the 20.04 version?

2 Answers

You can try the following:

sudo updatedb
locate Python.h

Output:

/usr/include/python2.7/Python.h
/usr/include/python3.5m/Python.h

Then set

export CPATH=/usr/include/python3.5m:$CPATH
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
0

Try installing the package libpython3.8-dev, that should put the Python.h file into /usr/include/python3.8/Python.h
Use apt-file search Python.h to find the packages that contain it. After installing apt-file, you will need to run apt-fil update to let it update its database.

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