Skip to content

emplaceAndPop(): incompatible function arguments with Python 3.10 and PyEval_InitThreads() warning #2347

@reinethernal

Description

@reinethernal

I am encountering an issue when trying to build and use OpenPose's Python bindings with Python 3.10. The pyopenpose module compiles, but when trying to run a Python script that uses openpose_wrapper.emplaceAndPop(), it fails with an incompatible function arguments error. Additionally, during compilation, a PyEval_InitThreads() deprecation warning is observed, originating from OpenPose's bundled pybind11.
Problem:
When calling openpose_wrapper.emplaceAndPop() from Python, I get the following error:

TypeError: emplaceAndPop(): incompatible function arguments. The following argument types are supported:

  1. emplaceAndPop(self: openpose.pyopenpose.WrapperPython, datum_vector: List[openpose.pyopenpose.Datum]) -> None
    Invoked with: <openpose.pyopenpose.WrapperPython object at 0x...>, None

(Note: The None in "Invoked with: ... None" is likely a symptom, not the root cause, as the object is initialized.)

During make compilation, I also see this warning, pointing to an outdated pybind11 being used:

In file included from /root/tryroom/openpose/3rdparty/pybind11/include/pybind11/cast.h:16,
from /root/tryroom/openpose/3rdparty/pybind11/include/pybind11/attr.h:13,
from /root/tryroom/openpose/3rdparty/pybind11/include/pybind11/pybind11.h:44,
from /root/tryroom/openpose/python/openpose/openpose_python.cpp:8:
/root/tryroom/openpose/3rdparty/pybind11/include/pybind11/detail/internals.h: In function ‘pybind11::detail::internals& pybind11::detail::get_internals()’:
/root/tryroom/openpose/3rdparty/pybind11/include/pybind11/detail/internals.h:200:27: warning: ‘void PyEval_InitThreads()’ is deprecated [-Wdeprecated-declarations]
200 | PyEval_InitThreads();
| ~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/python3.10/Python.h:130,
from /root/tryroom/openpose/3rdparty/pybind11/include/pybind11/detail/common.h:112,
...
/usr/include/python3.10/ceval.h:122:37: note: declared here
122 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);

Environment:

  • OpenPose Version: (Specify the version you are using, e.g., the commit hash if cloned from git, or the release version if downloaded)
  • Operating System: Ubuntu 22.04 LTS
  • Python Version: 3.10
  • CUDA Version: 12.6
  • cuDNN Version: 9.7.1
  • GCC Version: 11.4.0
  • OpenCV Version: 4.5.4 (as reported by CMake)

Steps Taken (and their outcomes):

  1. Clean build of OpenPose.
  2. Explicitly set Python paths during CMake configuration:
    cmake .. \
        -DBUILD_PYTHON=ON \
        -DPYTHON_EXECUTABLE=/root/tryroom/venv/bin/python3 \
        -DPYTHON_INCLUDE_DIR=/root/tryroom/venv/include/python3.10 \
        -DPYTHON_LIBRARY=/root/tryroom/venv/lib/libpython3.10.so \
        -DUSE_CUDA=ON \
        -DBUILD_CAFFE=ON \
        -DOpenCV_DIR=/usr/local/opencv/build \
        -DCUDNN_INCLUDE_DIR=/usr/local/cuda/include \
        -DCUDNN_LIBRARY=/usr/local/cuda/lib64
    Result: CMake proceeds, but warns "Manually-specified variables were not used by the project: ... PYTHON_EXECUTABLE, PYTHON_INCLUDE_DIR, PYTHON_LIBRARY".
  3. Attempted to force system pybind11 using USE_SYSTEM_PYBIND11=ON flag:
    Result: This flag was also ignored by CMake.
  4. Modified openpose/python/openpose/CMakeLists.txt to add find_package(pybind11 CONFIG REQUIRED) before pybind11_add_module.
    Result: CMake did not report finding pybind11 explicitly, and Python-related variables were still warned as unused. The PyEval_InitThreads() warning persists during make.

Observation:
The compilation warning explicitly points to openpose/3rdparty/pybind11/, indicating that OpenPose is using its bundled, likely outdated, pybind11 which is incompatible with Python 3.10's API (specifically PyEval_InitThreads deprecation). The CMake configuration seems to override attempts to use an external pybind11 or explicitly specified Python paths.

Expected behavior:
OpenPose Python bindings should compile and run correctly with Python 3.10, utilizing a compatible pybind11 version.

Any guidance or known workarounds for this compatibility issue would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions