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.

For apt (Ubuntu, Debian...):

sudo apt install python-dev   # for python2.x installs
sudo apt install python3-dev  # for python3.x installs

For yum (CentOS, RHEL...):

sudo yum install python-devel    # for python2.x installs
sudo yum install python3-devel   # for python3.x installs

For dnf (Fedora...):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel  # for python3.x installs

For zypper (openSUSE...):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel  # for python3.x installs

For apk (Alpine...):

# This is a departure from the normal Alpine naming
# scheme, which uses py2- and py3- prefixes
sudo apk add python2-dev  # for python2.x installs
sudo apk add python3-dev  # for python3.x installs

For apt-cyg (Cygwin...):

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

Important Note: python3-dev/devel does not automatically cover all minor versions of python3.
E.g If you are using python 3.11 you may need to install python3.11-dev / python3.11-devel.

Answer from wim on Stack Overflow
🌐
GitHub
github.com › python › cpython › blob › main › Include › Python.h
cpython/Include/Python.h at main · python/cpython
// C extensions should only #include <Python.h>, and not include directly · // the other Python header files included by <Python.h>. · #ifndef Py_PYTHON_H · #define Py_PYTHON_H · · // Since this is a "meta-include" file, "#ifdef __cplusplus / extern "C" {" // is not needed.
Author: python
Top answer
1 of 16
3620

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.

For apt (Ubuntu, Debian...):

sudo apt install python-dev   # for python2.x installs
sudo apt install python3-dev  # for python3.x installs

For yum (CentOS, RHEL...):

sudo yum install python-devel    # for python2.x installs
sudo yum install python3-devel   # for python3.x installs

For dnf (Fedora...):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel  # for python3.x installs

For zypper (openSUSE...):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel  # for python3.x installs

For apk (Alpine...):

# This is a departure from the normal Alpine naming
# scheme, which uses py2- and py3- prefixes
sudo apk add python2-dev  # for python2.x installs
sudo apk add python3-dev  # for python3.x installs

For apt-cyg (Cygwin...):

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

Important Note: python3-dev/devel does not automatically cover all minor versions of python3.
E.g If you are using python 3.11 you may need to install python3.11-dev / python3.11-devel.

2 of 16
581

On Ubuntu, I was running Python 3 and I had to install

sudo apt-get install python3-dev

If you want to use a version of Python that is not linked to python3, install the associated python3.x-dev package. For example:

sudo apt-get install python3.5-dev
🌐
Python
docs.python.org › 3 › c-api › intro.html
Introduction — Python 3.14.7 documentation
All user visible names defined by Python.h (except those defined by the included standard headers) have one of the prefixes Py or _Py. Names beginning with _Py are for internal use by the Python implementation and should not be used by extension writers.
🌐
Reddit
reddit.com › r/c_programming › using #include
r/C_Programming on Reddit: Using #include <Python.h>
April 5, 2023 -

I'm trying to write a Python library in C. My code uses #include <Python.h> but VSCode says:

"include errors detected. Please update your includePath. Squiggles are disabled for this translation unit."

What does this mean and how do I go about fixing this? (Sorry if it's obvious, I'm not new to Python but very new to C)

🌐
GitHub
github.com › Yikun › Python3 › blob › master › Include › Python.h
Python3/Include/Python.h at master · Yikun/Python3
#ifndef Py_PYTHON_H · #define Py_PYTHON_H · /* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ · /* Include nearly all Python header files */ · #include "patchlevel.h" #include "pyconfig.h" #include "pymacconfig.h" · #include <limits.h> ·
Author: Yikun
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-fatal-error-python-h-no-such-file-or-directory
How to fix: "fatal error: Python.h: No such file or directory" - GeeksforGeeks
July 23, 2025 - The error message "fatal error: ... is unable to find the Python.h header file, which is part of the Python development package required for compiling C/C++ code that interacts with Python....
Find elsewhere
🌐
AskPython
askpython.com › python › examples › fix-gcc-python-h-no-such-file
[Fix] gcc - fatal error: Python.h: No such file or directory - AskPython
April 10, 2025 - This error occurs because the compiler cannot find the Python developer files it needs to build the extension or package. But don’t worry – in most cases, it can be easily fixed!
🌐
Python
svn.python.org › projects › python › trunk › Include › Python.h
Python.h
#ifndef Py_PYTHON_H #define Py_PYTHON_H /* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ /* Include nearly all Python header files */ #include "patchlevel.h" #include "pyconfig.h" #include "pymacconfig.h" /* Cyclic gc is always enabled, starting with release 2.3a1.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 27086248960402-How-to-get-Python-h-in-Header-Search-Paths
How to get Python.h in Header Search Paths – IDEs Support (IntelliJ Platform) | JetBrains
May 31, 2025 - Please take a look at this thread, for example. You don't need to add a Python interpreter in CLion (CLion | Settings | Build, Execution, Deployment | Python Interpreter). However, you need to add the following lines to your CMakeLists.txt file
🌐
GitHub
github.com › Python-H
Python-H - Overview
Python-H has one repository available. Follow their code on GitHub.
🌐
Jam
jam.dev › blog › python-fatal-error-python-h-no-such-file-or-directory
Fixing Fatal Error: python.h: No Such File or Directory | Easy Solutions
October 3, 2024 - Typically, this error occurs when the C compiler fails to locate the necessary python.h header file.
🌐
GitHub
github.com › astral-sh › uv › issues › 1579
fails to find "Python.h", while pip works · Issue #1579 · astral-sh/uv
February 17, 2024 - error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 --- Caused by: This error likely indicates that you need to install a library that provides "Python.h" for pysha3==1.0.2 pip install pysha3==1.0.2 Collecting pysha3==1.0.2 Using cached pysha3-1.0.2-cp310-cp310-linux_x86_64.whl Installing collected packages: pysha3 Successfully installed pysha3-1.0.2
Author: astral-sh
🌐
Finxter
blog.finxter.com › home › learn python blog › [fixed] fatal error: python.h: no such file or directory
[FIXED] fatal error: Python.h: No such file or directory - Be on the Right Side of Change
December 18, 2021 - Most probably, when you face this error, it’s because you have not installed the static libraries and the header files properly. Hence to solve the error, you need to use the package manager to install them on the PC. Use the following commands according to the OS installed on your system. Caution: The above command only works if you are using either Python 2 or Python 3 version.
🌐
BetterBugs
betterbugs.io › blog › how-to-fix-fatal-error-python-h-no-such-file-or-directory
How to Fix “Fatal Error: Python.h: No Such File or Directory” in Python [Updated]
June 10, 2024 - Missing Python env variables — env variables (such as CPATH, CPLUS_INCLUDE_PATH, and C_INCLUDE_PATH) direct the system to find required Python modules and headers to interact with C/C++. If these are not set or are set incorrectly, the system will not be able to locate the “python.h” file, even if it exists on your machine.
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Can't find Python.h trying to make wrapper (SOLVED) - Raspberry Pi Forums
Thank you. I ran apt-get update and apt-get upgrade, before that I could not even get the Python.h for 2.7 Now I'll just have to figure out the issue for 3.2, but that is less urgent as 2.7 now works with RoboPi
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1338544 › python-h
Не могу не как понять как установить библиотеку Python.h - Microsoft Q&A
July 28, 2023 - A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.