【问题标题】:How to use same lib different versions from cpp and python如何使用来自 cpp 和 python 的相同 lib 不同版本
【发布时间】:2023-01-01 18:04:55
【问题描述】:
我有一个项目同时使用 python 和 cpp(和 cython 在两者之间进行连接)。
在 python 中,我使用“import pyarrow”(版本 6.0.0)
在 cpp 中,我刚刚为 libarrow 版本 10.0.1 添加了一个用途(我使用 CMAKE)
这在运行 python 时导致了分段错误(cpp 端有效)
我尝试使用:
'pyarrow.require("pyarrow==6.0.0")'
在 python 中,但没有帮助
【问题讨论】:
标签:
python
c++
cython
static-linking
lib
【解决方案1】:
您使用的 C++ Arrow 库版本(版本 10.0.1)似乎与您在 Python 代码中使用的 Python Arrow 库(版本 6.0.0)不兼容。
一种解决方案是在 Python 和 C++ 代码中使用相同版本的 Arrow 库。您可以通过将 C++ Arrow 库降级到版本 6.0.0 或将 Python Arrow 库升级到版本 10.0.1 来执行此操作。
或者,您可以尝试使用 Cython 包装 C++ Arrow 库,然后将其导入您的 Python 代码。这将允许您使用更新版本的 C++ Arrow 库,同时仍保持与 Python 代码的兼容性。
我希望这有帮助!如果您还有其他问题,请告诉我。