Search code examples
pythonpy2exe

Py2exe and psycopg, build on Windows 10, can't run on Windows 7


I'm using Python 2.7 with psycopg. If I use py2exe to build the executable on Windows 7 (with full bundling), the resulting .exe runs fine on Windows 7 and 10. If I build the .exe on Windows 10, however, then it runs fine on Windows 10, but on Windows 7 gives the dreaded:

Traceback (most recent call last):
  File "test.opy", line 2, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "psycopg2\__init__.pyo", line 50, in <module>
  File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading psycopg2\_psycopg.pyd

Here I'm using a test.py which is literally just:

import psycopg2
print "It worked!"

Anyone have any ideas as to what I should try next?

PS: This is definitely an issue with the bundling - unbundled it works fine, but that isn't ideal for what I want.


Solution

  • Add this to the options dict in setup.py:

    'dll_excludes': ['Secur32.dll', 'SHFOLDER.dll', 'CRYPT32.dll']