Src/pyodbc.h:45:10: fatal error: Python.h: No such file or directory

Hi @Allan_Zimmermann,
I was doing an experiment on agents, after going through you latest video on youtube. I used the python boiler plate and added some code under _ProcessWorkItem function. that uses pyodbc lib to read and update data in ms sql server. added same in requirement.txt

when I am running the boiler plate as is, running fine
when I am running the modified package getting the following error,
Child process 113 exited with code 1
ModuleNotFoundError: No module named ‘openiap’
import asyncio, os, openiap, traceback, zlib, json, logging
File “/root/.openiap/packages/651fbdb9be25a045ebd33970/pyworkitemagent-main/main.py”, line 1, in
Traceback (most recent call last):
Child process started as pid 113
Child process 48 exited with code 1
ERROR: Could not build wheels for pyodbc, which is required to install pyproject.toml-based projects
Failed to build pyodbc
ERROR: Failed building wheel for pyodbc
note: This error originates from a subprocess, and is likely not a problem with pip.

  [end of output]
  error: command '/usr/bin/gcc' failed with exit code 1
  compilation terminated.
        |          ^~~~~~~~~~
     45 | #include <Python.h>
  src/pyodbc.h:45:10: fatal error: Python.h: No such file or directory
  In file included from src/buffer.cpp:12:
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Os -fomit-frame-pointer -g -O2 -Os -fomit-frame-pointer -g -O2 -Os -fomit-frame-pointer -g -O2 -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPYODBC_VERSION=4.0.39 -I/usr/include/python3.10 -c src/buffer.cpp -o build/temp.linux-x86_64-cpython-310/src/buffer.o -Wno-write-strings
  creating build/temp.linux-x86_64-cpython-310/src
  creating build/temp.linux-x86_64-cpython-310
  building 'pyodbc' extension
  running build_ext
  copying src/pyodbc.pyi -> build/lib.linux-x86_64-cpython-310
  creating build/lib.linux-x86_64-cpython-310
  creating build
  running build_py
  running build
  running bdist_wheel
  WARNING: '' not a valid package name; please use only .-separated package names in setup.py

╰─> [18 lines of output]
│ exit code: 1
× Building wheel for pyodbc (pyproject.toml) did not run successfully.

error: subprocess-exited-with-error
Building wheel for pyodbc (pyproject.toml): finished with status ‘error’
Building wheel for pyodbc (pyproject.toml): started
Building wheels for collected packages: pyodbc
Requirement already satisfied: six>=1.5 in /usr/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas->-r /root/.openiap/packages/651fbdb9be25a045ebd33970/pyworkitemagent-main/requirements.txt (line 2)) (1.16.0)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 341.8/341.8 kB 7.8 MB/s eta 0:00:00
Downloading tzdata-2023.3-py2.py3-none-any.whl (341 kB)
Collecting tzdata>=2022.1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 7.7 MB/s eta 0:00:00
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting python-dateutil>=2.8.2
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.0/18.0 MB 8.0 MB/s eta 0:00:00
Downloading numpy-1.26.0-cp310-cp310-musllinux_1_1_x86_64.whl (18.0 MB)
Collecting numpy>=1.22.4
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 134.5/134.5 kB 7.3 MB/s eta 0:00:00
Downloading websockets-11.0.3-cp310-cp310-musllinux_1_1_x86_64.whl (134 kB)
Collecting websockets
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.7/175.7 kB 7.3 MB/s eta 0:00:00
Downloading protobuf-4.24.4-py3-none-any.whl (175 kB)
Collecting protobuf
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.5/5.5 MB 8.2 MB/s eta 0:00:00
Downloading grpcio-1.59.0-cp310-cp310-musllinux_1_1_x86_64.whl (5.5 MB)
Collecting grpcio
Preparing metadata (pyproject.toml): finished with status ‘done’
Preparing metadata (pyproject.toml): started
Installing backend dependencies: finished with status ‘done’
Installing backend dependencies: started
Getting requirements to build wheel: finished with status ‘done’
Getting requirements to build wheel: started
Installing build dependencies: finished with status ‘done’
Installing build dependencies: started
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 282.4/282.4 kB 7.8 MB/s eta 0:00:00
Downloading pyodbc-4.0.39.tar.gz (282 kB)
Collecting pyodbc
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 502.5/502.5 kB 7.9 MB/s eta 0:00:00
Downloading pytz-2023.3.post1-py2.py3-none-any.whl (502 kB)
Collecting pytz
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.1/13.1 MB 7.9 MB/s eta 0:00:00
Downloading pandas-2.1.1-cp310-cp310-musllinux_1_1_x86_64.whl (13.1 MB)
Collecting pandas
Downloading openiap-0.0.32-py3-none-any.whl (31 kB)
Collecting openiap
Child process started as pid 48


**** Running pip install


Child process started as pid 48


**** Running pip install


Hi @Manash

For what I can see in the logs error messages and you provided point to a couple of issues:

  1. ModuleNotFoundError: No module named ‘openiap’: This indicates that Python cannot find the ‘openiap’ module. Ensure that it’s installed and available in your Python environment.
  2. The error “fatal error: Python.h: No such file or directory” indicates that the Python development headers are missing. This is required to compile some Python extensions.
  3. ERROR: Failed building wheel for pyodbc: This suggests that there was an issue building the pyodbc module.

Are you using a Linux distribution? If so, which one?
I might have some solution but that’s depende on your Linux distribution.

Openflow is installed in ubuntu, using letsencypt yaml.

uploaded the package and ran through an agent

does it work with the boilerplate code ?
Can you run that locally and in the agent ?
If so, then it’s not openiap giving the issue, but one/some of the other packages you are trying to install
For instance, some ML packages install and old version of GRPC, so often need to force update that.

boiler plate works fine.
the program can run the python code locally in my pc with pyodbc library, but not in agent.
requirement.txt contents
openiap
pandas
pytz
pyodbc

seems something with pyodbc library

Hi @Allan_Zimmermann,
I tried again, this time I again used the github boilerplate GitHub - openiap/pyworkitemagent and only added pyodbc library in requirement.txt. zipped and uploaded. ran the agent, same error.

I really don’t know then … my best guess is, build tools are missing, but I know those are already added in my agent image ( since i need those for langchain and panda )
Sorry, I’m not a python man myself, so not sure what that could be.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.