py2exe throws ImportError: DLL load failed: The specified module could not be found

FINALLY, I can die a happy man. After agonizing over this problem for over a week, I figured out that the issue is that I had to download the 64bit version of py2exe from SourceForge. The "Get Latest Version" link that they have at the top is for Python 2.5, which is very misleading because I would have assumed it would at least use the latest version of PYTHON that it supports, which I believe is the version I have, Python 2.7.1.

I had to go into the "Browse All Files" section and manually navigate to v0.6.9 and then pick the appropriate version.

I am now able to create an executable from running "C:\Python27\setup.py py2exe".

thanks all for your help/replies.


The most important lines in that error are the last two -

import py2exe_util

ImportError: DLL load failed: The specified module could not be found.

That means py2exe was not installed completely in the first place. Try re-installing it.


You need a version of py2exe that matches the architecture of your python install. If you have a 32bit python install you need a win32 py2exe installer. If you have a x64 python install you need a win64 py2exe installer.

In my case I am on a 64bit machine with a 32bit python install. The Source Forge 'latest' link gave the win64 version of py2exe (because it detected my machine type). But it didn't work, I kept getting the following error:

ImportError: DLL load failed with error code 193

I needed to go back to Source Forge and 'Browse all files' to find the win32 version.

Tags:

Python

Py2Exe