I realized a C++ project and I used pydbind11. All work fine on Linux (C++ compilation with CMake produces test executables and Python module that works when I import it, installation with pip install works too). On Windows, I compile the project with MSYS2 UCRT64 in a MSYS2 UCRT64 prompt. To launch .exe files, I need to launch them in a CMD prompt instead of a MSYS2 UCRT64 prompt, I don't know why. The compilation produces a .pyd file in build folder but I don't arrive to import it. I create a symreg folder at root project and I copy the .pyd file into with the appropriate DLL files. I try too with a __init__.py file with the following content:
from .symreg import *
Here is the output in MSYS2 UCRT64 prompt:
Julien@DESKTOP-0IQSQEO UCRT64 ~/symreg_ws/SymReg
$ ls symreg/
__init__.py libblas.dll libglog-2.dll libstdc++-6.dll zlib1.dll
__pycache__ libceres-4.dll libgvc-6.dll libwinpthread-1.dll
libarmadillo.dll libgcc_s_seh-1.dll libopenblas.dll symreg.cp312-win_amd64.pyd
Julien@DESKTOP-0IQSQEO UCRT64 ~/symreg_ws/SymReg
$ python
Python 3.12.11 (main, Jun 7 2025, 12:31:34) [GCC UCRT 15.1.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import symreg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:/Programmes/msys64/home/Julien/symreg_ws/SymReg/symreg/__init__.py", line 1, in <module>
from .symreg import *
ModuleNotFoundError: No module named 'symreg.symreg'
Here is the output in CMD prompt:
D:\Programmes\msys64\home\Julien\symreg_ws\SymReg>D:\Programmes\msys64\ucrt64\bin\python.exe
Python 3.12.11 (main, Jun 7 2025, 12:31:34) [GCC UCRT 15.1.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import symreg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Programmes\msys64\home\Julien\symreg_ws\SymReg\symreg\__init__.py", line 1, in <module>
from .symreg import *
ModuleNotFoundError: No module named 'symreg.symreg'
For information, the project is here on GitHub with the MSYS2 commands to compile: https://github.com/Julien-Livet/SymReg.
I saw the gmpy2 package in site-packages folder and there is a .pyd file named gmpy2.cp312-mingw_x86_64_ucrt_gnu.pyd. I tried to rename my .pyd file with cp312-mingw_x86_64_ucrt_gnu.pyd extension but I obtained the following output:
>>> import symreg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:/Programmes/msys64/home/Julien/symreg_ws/SymReg/symreg/__init__.py", line 1, in <module>
from .symreg import *
ImportError: DLL load failed while importing symreg: Le module spécifié est introuvable.
I added api-ms-win-crt-*.dll files. What it is strange is that it requires python312.dll whereas there is only libpython3.12.dll and libpython.dll in ucrt64/bin folder. I tried to put libpython3.12.dll by renaming it in python312.dll but when I try to import the module, I obtained a segmentation fault.
Have you any idea to use this .pyd file correctly? And then of course, install it to use it in Python scripts?
CreateFilecalls by thepython.exeexecutable to see which file it tries to load when attempting the import?CreateFilecalls but nothing related to symreg.