compile a game with py2exe : DLL load failed

I try to compile with py2exe a simple script displaying a smiley in panda3d.

When I launch the exe file I got the following message

C:\Users\philippe\Documents\game\editor\test\wxpanda pyexe>main.exe

Warning: unable to auto-locate config files in directory named by "<auto>etc".
Traceback (most recent call last):
  File "main.py", line 7, in <module>
    from direct.task import Task
  File "direct\task\Task.pyc", line 10, in <module>
  File "direct\showbase\ExceptionVarDump.pyc", line 1, in <module>
  File "panda3d\direct.pyc", line 12, in <module>
  File "panda3d\direct.pyc", line 10, in __load
ImportError: DLL load failed: the specified module is not found.

My issue is that I can not read the source code in order to identified what what could be the DLL called at line 10 in the file C:\Panda3D-1.9.0-x64\panda3d\direct.pyd

Do you know how to get the source code for C:\Panda3D-1.9.0-x64\panda3d*.pyd ?
:question:

kind regards

Philippe

In the first few lines, direct.py imports “._direct”, which is a .pyd in the same module. So, it’s failing to import panda3d/_direct.pyd.

This error usually happens when a required .dll is not present. For example, _direct.pyd depends on Panda libraries such as libpanda.dll, which must either be present in the same directory or on the system PATH.

You can examine _direct.pyd in a tool like Dependency Walker to see which DLLs it depends on that need to be present.

py2exe generate a directory dist with the exe file and all the dll and pyd , … files

The libray missing was core.pyd but it is strange because the library is existing in the directory as panda3d.core.pyd

I have a new error :

C:\Users\philippe\Documents\game\editor\test\wxpanda pyexe\dist>main.exe
Warning: unable to auto-locate config files in directory named by "<auto>etc".
Attempt to register type PythonCallbackObject more than once!
Attempt to register type PythonTask more than once!
:interrogatedb(warning): Classes panda3d.core.TypedObject and panda3d.core.TypedObject share the same TypeHandle value (3); check class definitions.
:interrogatedb(warning): Classes panda3d.core.ReferenceCount and panda3d.core.ReferenceCount share the same TypeHandle value (4); check class definitions.
:interrogatedb(warning): Classes panda3d.core.TypedReferenceCount and panda3d.core.TypedReferenceCount share the same TypeHandle value (5); check class definitions.
Traceback (most recent call last):
  File "main.py", line 10, in <module>
  File "direct\showbase\ShowBase.pyc", line 26, in <module>
  File "direct\interval\IntervalManager.pyc", line 142, in <module>
  File "direct\interval\IntervalManager.pyc", line 32, in __init__
TypeError: CIntervalManager.set_event_queue() argument 1 must be panda3d.core.EventQueue, not panda3d.core.EventQueue

This looks like the Panda libraries were loaded more than once. Perhaps they exist twice under different names, but are still both loaded in.

You should try pfreeze, Nirai, or Nuitka instead of py2exe. If you’re trying to hide your source, Nirai is recommended, and py2exe just stores code in a zip file, so py2exe isn’t recommended. Pfreeze is easier to work with and a bit harder to decompile, but any advanced hacker can decompile it in a day. Nirai will solve all your problems; it uses a custom panda3d that uses static .lib files instead of .pyd’s (no core.pyd, but a core.lib that is initiated at runtime), and that should solve the issue you are getting.