Module use of python3_d.dll conflicts with this version of Python

Olivier B. perso.olivier.barthelemy at gmail.com
Thu Jan 26 08:11:12 EST 2023


Hi,I am in the process of trying to make my code (an c++ executable
and swig modules using the Python C API) lose the dependency to python
3.7, to be compatible with all Python 3.2+

I tried linking to python.lib instead of python37.lib. As i am still
using a few things that are not in the limited API, my binaries now
have a dependency to python3.dll for the base stuff, and pyhton37.dll
for the few symbols that are not backwards compatible.

In release, that does not seem to bring issues. In debug (debug build
of my program that uses python debug build) however, when the process
is importing the swig python/c++ module, i get a
"Module use of python3_d.dll conflicts with this version of Python". I
checked that i am properly loading the python3_d.dll of my python37,
and python python37_d.dll too

Looking in dynload_win.c of python sources where the message is
triggered, indeed it is comparing in py case python37_d.dll to
python3_d.dll.
And i guess, in release, it works because in GetPythonModule(), there' is

#ifndef _DEBUG
/* In a release version, don't claim that python3.dll is
a Python DLL. */
if (strcmp(import_name, "python3.dll") == 0) {
import_data += 20;
continue;
}
#endif

Does someone know why it would have been chosen to be different for
debug builds?


More information about the Python-list mailing list