utilsmodule.c:1:20: fatal error: Python.h: No such file or directory compilation terminated.
in fact I have tried all the suggested solutions over the internet but the problem still exists ... also I have no problem with Python.h. I managed to locate the file on my machine ... anybody has faced the same problem before??
Looks like you haven't properly installed the header files and static libraries for python dev. Use your package manager to install them system-wide.
If you are using tox to run tests on multiple versions of Python, you may need to install the Python dev libraries for each version of Python you are testing on.
You need to install the package python2-devel or python3-devel, depending on the Python version you're using.
You can quickly install it using the 32-bit or 64-bit setup.exe (depending on your installation) from Cygwin.com.
You can also check my other answer for a few more options to install Cygwin's packages from the command-line.
I found the file /usr/include/python2.7/Python.h, and since /usr/include is already in the include path, then python2.7/Python.h should be sufficient.
You could also add the include path from command line instead - gcc -I/usr/lib/python2.7 (thanks @erm3nda).
Make sure that the Python dev files come with your OS.
In my case, what fixed it in Ubuntu was to install the packages libpython-all-dev (or libpython3-all-dev if you use Python 3).
existe_wrap.c:147:21: fatal error: Python.h: No existe el archivo o el directorio compilation terminated.
If you use a virtualenv with a 3.6 python (edge right now), be sure to install the matching python 3.6 dev sudo apt-get install python3.6-dev, otherwise executing sudo python3-dev will install the python dev 3.3.3-1, which won't solve the issue.
try apt-file. It is difficult to remember the package name where the missing file resides. It is generic and useful for any package files.
Now you can make an expert guess as to which one to choose from.
I also encountered this error when I was installing coolprop in ubuntu.
If ever this doesn't work try installing/updating gcc lib.
This error occurred when I attempted to install ctds on CentOS 7 with Python3.6. I did all the tricks mentioned here including yum install python34-devel. The problem was Python.h was found in /usr/include/python3.4m but not in /usr/include/python3.6m. I tried to use --global-option to point to include dir (pip3.6 install --global-option=build_ext --global-option="--include-dirs=/usr/include/python3.4m" ctds). This resulted in a lpython3.6m not found when linking ctds.
Finally what worked was fixing the development environment for Python3.6 needs to correct with the include and libs.
Python.h needs to be in your include path for gcc. Whichever version of python is used, for example if it's 3.6, then it should be in /usr/include/python3.6m/Python.h typically.
Sure python-dev or libpython-all-dev are the first thing to (apt )install, but if that doesn't help as was my case, I advice you to install the foreign Function Interface packages by sudo apt-get install libffi-dev and sudo pip install cffi.
This should help out especially if you see the error as/from c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory.
It often appear when you trying to remove python3.5 and install python3.6.
So when using python3 (which python3 -V => python3.6) to install some packages required python3.5 header will appear this error.
Resolve by install python3.6-dev module.
Sometimes even after installing python-dev the error persists, Check for the error if it is 'gcc' missing.
This means that Python.h isn't in your compiler's default include paths. Have you installed it system-wide or locally? What's your OS?
You could use the -I<path> flag to specify an additional directory where your compiler should look for headers. You will probably have to follow up with -L<path> so that gcc can find the library you'll be linking with using -l<name>.
Not the answer you're looking for? Browse other questions tagged python gcc python-c-api python-c-extension or ask your own question.