Python.h Is Not Installed or Cannot Be Found During Dependency Installation

Symptom

During dependency installation, the message "fatal error:Python.h:No such file or directory" or "Could not find <Python.h>" is displayed, as shown in Figure 1 and Figure 2.

Figure 1 Prompt message 1 (example)
Figure 2 Prompt message 2 (example)

Possible Cause

The Python 3 development package does not exist in the environment.

Solution

Run the following commands to install the dependency based on the actual system:

  • apt-get install python3-dev
  • yum install python3-devel
  • dnf install python3-devel