gpt4 book ai didi

python - pybind11 - ImportError : undefined symbol: _Py_ZeroStruct

转载 作者:行者123 更新时间:2023-12-04 19:24:35 25 4
gpt4 key购买 nike

我正在关注 pybind11文档并尝试为简单函数创建 Python 绑定(bind) Creating bindings for a simple function ,但是在使用以下命令编译我的 C++ 代码后:

g++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cc -o example$(python3-config --extension-suffix)
当我尝试使用以下命令在 python 中导入库时:
import example
我得到一个 ImportErrorundefined symbol: _Py_ZeroStruct我在用着:
  • Ubuntu : Ubuntu 20.04.4 LTS
  • python : Python 3.8.10
  • : Pip 20.0.2

  • 我试图解决的问题
    我查看了许多与同一错误相关的文章,但无法真正了解我将如何解决我的问题:
  • Python3.5 incompatibility: undefined symbol
  • ImportError: undefined symbol: _Py_ZeroStruct
  • undefined symbol using pybind11 cmd
  • Undefined Symbol error when linking pybind11 with a dynamic library that calls an external function

  • 任何形式的帮助将不胜感激。

    最佳答案

    好吧,在尝试了很多方法后,我终于决定添加 pybind11作为我项目中的子模块并使用Python3.9这次似乎奏效了。
    任何遇到同样问题的人都可以试试我的方法,它可能会起作用,不要指望这个残酷社区的帮助 .

    关于python - pybind11 - ImportError : undefined symbol: _Py_ZeroStruct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72334552/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com