admin管理员组文章数量:1023758
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.
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.
本文标签: pythonBuilding pybind11 example successfullybut still got ImportErrorStack Overflow
版权声明:本文标题:python - Building pybind11 example successfully, but still got ImportError - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745606446a2158756.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论