arrow::py::import_pyarrow() 导致分段错误

arrow::py::import_pyarrow() cause a SEGMENTATION FAULT

我正在尝试使用 arrow-cpp 构建一个 Table 然后将其传输回 python。

为此,我需要事先调用 arrow::py::import_pyarrow(),但这会导致 SEGFAULT。

谁能帮我看看哪里做错了?

这是一个最小的例子

CMakeLists.txt

cmake_minimum_required(VERSION 3.20.0)
project(TEST)
set(CMAKE_CXX_STANDARD 17)
set(Python3_EXECUTABLE "/home/auderson/miniconda3/bin/python3.8")

list(APPEND CMAKE_PREFIX_PATH "/home/auderson/miniconda3/lib/cmake/arrow")
find_package(Arrow REQUIRED)
find_package(ArrowPython REQUIRED)
find_package(Python3 COMPONENTS Interpreter Development)


include_directories(.
        /home/auderson/miniconda3/lib/python3.8/site-packages/pyarrow/include
        ${Python3_INCLUDE_DIRS})

add_executable(TEST
        mini_t.cpp
        )

target_link_libraries(${PROJECT_NAME} PRIVATE arrow_shared)
target_link_libraries(${PROJECT_NAME} PRIVATE arrow_python_shared)
target_link_libraries(${PROJECT_NAME} PRIVATE ${Python3_LIBRARIES})

cpp 文件


#include "arrow/python/pyarrow.h"

int main() {
    return arrow::py::import_pyarrow();
}


输出(调试模式)

Signal: SIGSEGV (Segmentation fault)

Process finished with exit code 1

如果不处于调试模式:

Process finished with exit code 139

箭头的其他功能工作得很好。

C++ 应用程序未初始化 Python 解释器。这是一个正确执行此操作的示例 C++ 可执行文件:

https://github.com/apache/arrow/blob/8e43f23dcc6a9e630516228f110c48b64d13cec6/cpp/src/arrow/python/util/test_main.cc

也回答了这个问题

https://lists.apache.org/thread.html/ra6a5d523a1cf9a305ae9a57d7abb8d5afdfa252487165858aa24e323%40%3Cuser.arrow.apache.org%3E