Issue
I am trying to use the <Python.h> header file but I cannot get it to be found. I am using ubuntu 20.04. I have seen many similar questions on stack overflow but none solve my problem. I have tried doing:
sudo apt-get install python3.9-dev
but this does not resolve my problem. I can also do Windows but #include <Python.h> produced the same error on Windows and I couldn't resolve it there so I moved to ubuntu. I am using Python3.9. Please can I have some suggestions as to what could be the problem?
Solution
It's not clear exactly what the context is, but you may just need to do:
sudo apt-get install libpython3.9-dev
If that doesn't work, do something like:
CPPFLAGS="${CPPFLAGS} -I $(dirname $(dpkg -L libpython3.9-dev | grep Python.h))"
And make sure you compile with the appropriate flags. That is, if you are building with gcc
, use:
gcc $CPPFLAGS ...
Answered By - William Pursell Answer Checked By - David Goodson (WPSolving Volunteer)