Reputation: 119
I'm trying to use arrow-cpp to build a Table then transfer it back to python.
In order to do that, I need to call arrow::py::import_pyarrow() beforehand, but this will cause a SEGFAULT.
Can anyone help to find where I did wrong?
here is a minimal example
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})
#include "arrow/python/pyarrow.h"
int main() {
return arrow::py::import_pyarrow();
}
Signal: SIGSEGV (Segmentation fault)
Process finished with exit code 1
if not in debug mode:
Process finished with exit code 139
other functionalities of arrow work just fine.
Upvotes: 0
Views: 1269
Reputation: 105521
The C++ application does not initialize the Python interpreter. Here's an example C++ executable which does this correctly:
This was also answered on
Upvotes: 6