简体   繁体   中英

Python and C++ (Pybind11): Python Extension Module Import Error

I try to wrap a C++ - function with pybind to create a python-module . After compiling with Visual Studio I accomplished to create a .pyd file. I tried to import this file ( python>>> import pymodule ) but get this error:

Import Error: dynamic module does not define module export function (PyInit_pymodule)

Is it usually the right approach to import a .pyd file the way I explained above? Why do I get this error?

1a) You have to copy the .pyd file into the Python-installation folder (Lib-> side packages). 1b) You can open Python in the same folder where the .pyd - file is placed.

2) the python module must have the same name as the directory defined in CMake

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM