Debugging from within QT Creator #5481
Unanswered
SimonDev666
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am using PyBind to embed Python within my C++ code. I am using the latest QT, the latest PyBind, using Python 3.13.1 and running in Windows 10. I have nothing special setup in my Creator.
When i try to debug my code from within QT Creator, i get the following error:
"terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to import encodings module"
when i run my code in release, i get no error. i played around a bit and found it always get this runtime_error just before the
py::scoped_interpreter guard{}.
i can not find anyone talking about this kind of issue, so am a little confused as to what to do next.
my cmake for my QT code is:
cmake_minimum_required(VERSION 3.16)
project(TestQtPyBind001 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(PYBIND11_INCLUDE_LIB "C:/Program Files/Python313/Lib/site-packages/pybind11/include/pybind11")
set(PYBIND11_INCLUDE_DIR "C:/Program Files/Python313/Lib/site-packages/pybind11/include/")
include_directories(${PYBIND11_INCLUDE_DIR})
set(pybind11_DIR "C:/Program Files/Python313/Lib/site-packages/pybind11/share/cmake/pybind11")
find_package(Python3 REQUIRED)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
find_package(pybind11 REQUIRED HINTS "${Python3_SITELIB}")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
add_executable(TestQtPyBind001
main.cpp
)
target_link_libraries(TestQtPyBind001
PRIVATE
Qt::Core
PUBLIC
pybind11::embed
${PYTHON_LIBRARIES}
)
include(GNUInstallDirs)
install(TARGETS TestQtPyBind001
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
can anyone help please.
Beta Was this translation helpful? Give feedback.
All reactions