python3 cannot find the pyconfig.h file
background
When installing a python third-party library from source code, it often happens that the c/c++ header files and libraries that the library depends on cannot be found, especially when compiling and installing the c/c++ library by yourself. When I installed the allennlp library, a natural language processing library in pytorch, when I installed the jsonnet dependency library file, I couldn't find the file pyconfig.h, so I tried the following installation methods.
solve
Most online said that the lack of pyconfig.h file is mainly due to the lack of the corresponding python3-dev, libpython3-dev or python3.x-dev, libpython3.x-dev, as long as the corresponding library files are installed. The author here is the python3.7 environment, so only need to install
sudo apt install python3.7-dev libpython3.7-dev
This general problem can basically be solved. But the author cannot solve the problem. It keeps saying that after finding the file'/usr/include/python3.7m/pyconfig.h', it cannot find the x86_64-linux-gnu/python3.7m/pyconfig.h file, but when I find the file, the file The file was found in the folder'/usr/include/x86_64-linux-gnu/python3.7m/pyconfig.h'. In order to be able to compile, I created a new folder/x86_64- under /usr/include/python3.7m/ linux-gnu/python3.7m/, then copy the file'/usr/include/x86_64-linux-gnu/python3.7m/pyconfig.h' to this folder, and then compile and install successfully.
In addition, you can refer to the following blog post
to add c:c++ header file or library search path to setup.py. Modifying the compiled file directory contained in extensions in the file setup.py may also solve this problem, but the author did not try.