Fatal error: pyconfig.h: No such file or directory

I need to rebuild my py venv (v3.10.12). Following the ‘documentation’ here, I am able to successfully build and and create a venv. However, when trying to run anything with dynamo on the GPU, I get:

Python-3.10.12/Include/Python.h:8:10: fatal error: pyconfig.h: No such file or directory
    8 | #include "pyconfig.h"

Example:

model = torchvision.models.resnet50().to_cuda()
modelComp = torch.compile(model) #no error
model(input)                     #error here

I have tried installing dependencies prior to build:

sudo apt-get build-dep python3
sudo apt-get install pkg-config
sudo apt-get install libssl-dev libffi-dev

With no luck.

Environment:

torch vision built from source and installed with

pip install -e /path/to/vision/
torch: 2.3.0+cu121
python 3.10.12

Please let me know if there is any other information needed.

I haven’t seen this issue before, but maybe python-dev is needed. I use minicoda/forge to manage virtual Python environments and a quick find / -name pyconfig.h shows it’s available in all envs.
CC @malfet in case you’ve seen this issue before (I didn’t find anything on GitHub besides a Windows issue).

1 Like

Yes, it exists:
/agoldf6/Python-3.10.12/pyconfig.h
Although it is not in:
/agoldf6/Python-3.10.12/Include

Moving it in there manually seemed to fix the issue. I don’t want to make this as resolved, as I still do not understand what went wrong when created the environment.

I am trying to compile

lemon@clx:~/myfrida/frida$ sudo make
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/lemon/myfrida/frida/deps/toolchain-linux-x86_64/bin/ninja
[1/2] Compiling C object subprojects/frida-python/frida/_frida/_frida.abi3.so.p/extension.c.o
FAILED: subprojects/frida-python/frida/_frida/_frida.abi3.so.p/extension.c.o
/usr/bin/cc -Isubprojects/frida-python/frida/_frida/_frida.abi3.so.p -Isubprojects/frida-python/frida/_frida -I../subprojects/frida-python/frida/_frida -Isubprojects/frida-core/src/api -I../subprojects/frida-core/src/api -Isubprojects/frida-gum -I../subprojects/frida-gum -Isubprojects/frida-gum/gum -I../subprojects/frida-gum/gum -I../subprojects/frida-gum/gum/arch-x86 -I../subprojects/frida-gum/gum/arch-arm -I../subprojects/frida-gum/gum/arch-arm64 -I../subprojects/frida-gum/gum/arch-mips -Isubprojects/frida-gum/libs -I../subprojects/frida-gum/libs -Isubprojects/frida-gum/libs/gum/heap -I../subprojects/frida-gum/libs/gum/heap -Isubprojects/frida-gum/libs/gum/prof -I../subprojects/frida-gum/libs/gum/prof -I../subprojects/frida-gum/gum/backend-linux/include -I../subprojects/frida-gum/gum/backend-elf -I../subprojects/frida-gum/gum/backend-libunwind/include -Isubprojects/frida-gum/bindings -I../subprojects/frida-gum/bindings -I/usr/lib/include/python3.10 -I/usr/lib/include/x86_64-linux-gnu/python3.10 -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/glib-2.0 -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/lib/glib-2.0/include -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/gee-0.8 -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/json-glib-1.0 -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/capstone -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/libsoup-3.0 -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/quickjs -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/gio-unix-2.0 -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/libusb-1.0 -I/home/lemon/myfrida/frida/deps/sdk-linux-x86_64/include/nice -fvisibility=hidden -fdiagnostics-color=always -DNDEBUG -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Os -g -ffunction-sections -fdata-sections -fPIC -pthread -DNGTCP2_STATICLIB -DNGHTTP2_STATICLIB -DGUM_STATIC -DFFI_STATIC_BUILD -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS -DPy_LIMITED_API=0x03070000 -MD -MQ subprojects/frida-python/frida/_frida/_frida.abi3.so.p/extension.c.o -MF subprojects/frida-python/frida/_frida/_frida.abi3.so.p/extension.c.o.d -o subprojects/frida-python/frida/_frida/_frida.abi3.so.p/extension.c.o -c ../subprojects/frida-python/frida/_frida/extension.c
../subprojects/frida-python/frida/_frida/extension.c:33:11: fatal error: pyconfig.h: No such file or directory
   33 | # include <pyconfig.h>
      |           ^~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
Command '['/usr/bin/python3', '/home/lemon/myfrida/frida/releng/meson/meson.py', 'compile']' returned non-zero exit status 1.
make: *** [Makefile:4: all] Error 1
lemon@clx:~/myfrida/frida$ ls /usr/include/python3.10/pyconfig.h
/usr/include/python3.10/pyconfig.h

The environment I am using is WSL Ubuntu

I tried asking GPT, but it didn’t solve my problem

I saw that you solved the problem, but I couldn’t find the file ‘Include’

lemon@clx:/usr/include/python3.10$ ls
Python.h           compile.h              exports.h             interpreteridobject.h  namespaceobject.h  pyerrors.h     pystrcmp.h      token.h
abstract.h         complexobject.h        fileobject.h          intrcheck.h            object.h           pyexpat.h      pystrhex.h      traceback.h
bltinmodule.h      context.h              fileutils.h           iterobject.h           objimpl.h          pyframe.h      pystrtod.h      tracemalloc.h
boolobject.h       cpython                floatobject.h         listobject.h           opcode.h           pyhash.h       pythonrun.h     tupleobject.h
bytearrayobject.h  datetime.h             frameobject.h         longintrepr.h          osdefs.h           pylifecycle.h  pythread.h      typeslots.h
bytesobject.h      descrobject.h          funcobject.h          longobject.h           osmodule.h         pymacconfig.h  rangeobject.h   unicodeobject.h
cellobject.h       dictobject.h           genericaliasobject.h  marshal.h              patchlevel.h       pymacro.h      setobject.h     warnings.h
ceval.h            dynamic_annotations.h  genobject.h           memoryobject.h         py_curses.h        pymath.h       sliceobject.h   weakrefobject.h
classobject.h      enumobject.h           graminit.h            methodobject.h         pycapsule.h        pymem.h        structmember.h
code.h             errcode.h              import.h              modsupport.h           pyconfig.h         pyport.h       structseq.h
codecs.h           eval.h                 internal              moduleobject.h         pydtrace.h         pystate.h      sysmodule.h

English is not my native language; please excuse typing errors.