Python 3 fatal error: Python.h: No such file or directory
During installation of project requirements (with PyCharm 2018.0 and Linux Mint 19) I faced error:
fatal error: Python.h: No such file or directory
the error seems to be related to missing developement packages for a given operating system. The solution is sinple:
sudo apt-get install python3.6-dev
or depending on your python version you can use different development packages(for Python 3.7):
sudo apt-get install python3.7-dev
More information and solution for this error can be found here: fatal error: Python.h: No such file or directory
Full errors details:
Executed command:
pip install mymodule==1.3.2
Error occurred:
src/twisted/test/raiser.c:4:10: fatal error: Python.h: No such file or directory
Proposed solution:
Make sure that you have installed Python development packages for your operating system.
Command output:
warning: BuildPy3: byte-compiling is disabled, skipping.
running build_ext
building 'twisted.test.raiser' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
creating build/temp.linux-x86_64-3.6/src/twisted
creating build/temp.linux-x86_64-3.6/src/twisted/test
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -I/home/user/Software/environments/myenv36/include/python3.6m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.6/src/twisted/test/raiser.o
src/twisted/test/raiser.c:4:10: fatal error: Python.h: No such file or directory
#include "Python.h"
^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for Twisted
Command "/home/user/Software/environments/myenv36/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pycharm-packaging/Twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-kohr7zqk/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/Software/environments/myenv36/include/site/python3.6/Twisted" failed with error code 1 in /tmp/pycharm-packaging/Twisted/