python - Building pybind11 example successfully, but still got ImportError - Stack Overflow

I'm trying to use pybind for the first time. I tried different ways, but eventually I decided to g

I'm trying to use pybind for the first time. I tried different ways, but eventually I decided to go with the 'official' PyBind11 example.

I did the following steps:

  • install Visual Studio Build Tools 2022 (I choose Desktop development with C++)
  • launch "x64 Native Tools Command Prompt for VS 2022"
  • navigate to the directory where I have the Python venv created
  • activate venv
  • clone cmake_example from PyBind11: git clone --recursive .git
  • run: python ./cmake_example/setup.py install - finished successfully
  • run: python ./cmake_example/setup.py build finished successfully.

The last line printed by the script is: cmake_example.vcxproj -> D:\Git\pybindtest\build\lib.win-amd64-cpython-311\cmake_example.cp311-win_amd64.pyd, so I believe everything is built successfully.

However, when trying to run .\cmake_example\tests\test_basic.py, I'm getting a standard error:

Traceback (most recent call last):
  File "D:\Git\pybindtest\cmake_example\tests\test_basic.py", line 1, in <module>
    import cmake_example as m
ImportError: dynamic module does not define module export function (PyInit_cmake_example)

I got the same error when manually type import cmake_example in Python console.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745606447a4635701.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信