fatal error: Python.h: No such file or directory 45 | #include <Python.h> | ^~~~~~~~~~ compilation terminated. error: command 'gcc' failed with exit status 1 code example
Example 1: Python.h: No such file or directory
For apt (Ubuntu, Debian...):
sudo apt-get install python-dev
sudo apt-get install python3-dev
For yum (CentOS, RHEL...):
sudo yum install python-devel
sudo yum install python3-devel
For dnf (Fedora...):
sudo dnf install python2-devel
sudo dnf install python3-devel
For zypper (openSUSE...):
sudo zypper in python-devel
sudo zypper in python3-devel
For apk (Alpine...):
sudo apk add python2-dev
sudo apk add python3-dev
For apt-cyg (Cygwin...):
apt-cyg install python-devel
apt-cyg install python3-devel
Example 2: fatal error: Python.h: No such file or directory 45 | #include | ^~~~~~~~~~ compilation terminated. error: command 'gcc' failed with exit status 1
sudo yum install python-devel
sudo yum install libevent-devel
sudo easy_install gevent
Example 3: fatal error: Python.h: No such file or directory 45 | #include | ^~~~~~~~~~ compilation terminated. error: command 'gcc' failed with exit status 1
sudo yum install python-devel
sudo yum install libevent-devel