8

I cannot seem to get py2exe to work properly. I have run "python setup.py py2exe" in cmd, as well as "python setup.py install"... and When I try to run my executable setup, I get this same error over and over:

enter image description here

After a week I'm starting to get quite frustrated and I'm hoping to be able to resolve the issue today.

I'm using Python 2.7 and py2exe v0.6.9. 64-bit Windows7

Skizz
  • 1,405
  • 2
  • 11
  • 12

4 Answers4

6

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.

Skizz
  • 1,405
  • 2
  • 11
  • 12
3

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.

jhocking
  • 5,527
  • 1
  • 24
  • 38
  • Okay, I've resinstalled it for the third time now. Is there a .py file I need to run? If so, what is the file? Does it need to be run in cmd? – Skizz Apr 01 '11 at 15:03
  • Describe exactly the procedure you are doing to install it. Perhaps you aren't installing it correctly. – jhocking Apr 01 '11 at 15:09
  • I downloaded the .msi from forge, and I run it. I install it to my C:\Python27 directory. After the .msi completes the install, I go to command prompt and set the path so C:\Python27. I then enter "setup.py py2exe" ... So the line looks like this: – Skizz Apr 01 '11 at 15:23
  • Doh, stupid enter button. the line looks like this: "C:\Python27 – Skizz Apr 01 '11 at 15:24
  • What is setup.py anyway? I didn't notice until now that you are running it from your python directory. I assumed that was the setup script for your program, but then it wouldn't be in the main python directory. – jhocking Apr 01 '11 at 18:11
  • Also, note this documentation refers to a dll you have to add manually, I don't know if that's relevant http://www.py2exe.org/index.cgi/Tutorial#Step5 – jhocking Apr 01 '11 at 18:14
  • Somebody on another forum said something about using it to setup py2xe, but I'm not exactly sure. I'm brand new to Python and don't know a whole lot about it or it's components. I would have figured the .msi would have been all the install required. Does my install sequence sound like it was done properly? – Skizz Apr 01 '11 at 18:15
  • Where might I find that MSVCR90.dll? I don't see a direct link on the link you provided or anything. I also did a search for this .dll on my HDD and found nothing. Perhaps this is in fact the problem. At least I hope so :P – Skizz Apr 01 '11 at 18:18
  • Alright, I ran that .exe from the link, and verified the version of the .exe seems to be correct. Once again, I ran "setup.py py2exe" and recieved the same error in cmd. – Skizz Apr 01 '11 at 18:21
  • That command is to use py2exe, not install it. I would think there'd be a different error if there was a problem in setup.py but you might as well post the code from in there. – jhocking Apr 01 '11 at 18:26
  • from distutils.core import setup import py2exe setup(console=['numbers.py']) – Skizz Apr 01 '11 at 18:32
2

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.

Keir
  • 21
  • 2
0

I'm not sure my problem is the same as OPs, but since I found this thread while searching for a solution to my problem, I'll add what I found.

My issue was building 32 bit program on a 64 bit machine. The exe worked fine on other 64 bit machines, but raised the DLL load failed: The specified module could not be found error on other 32 bit machines.

What I ended up figuring out was that py2exe was including windows DLLs that it shouldn't have been in the package. When these DLLs were removed, the error went away.

py2exe has an option to explicitly exclude dlls. Here's a snippet of what worked for me:

setup(
    ...
    options={
        'bdist_esky': {
            'freezer_module': 'py2exe',
            'freezer_options': {
                'dll_excludes': [
                    'CRYPT32.dll',
                    'IPHLPAPI.DLL',
                    'MPR.dll',
                    'MSWSOCK.dll',
                    'PSAPI.DLL',
                    'WTSAPI32.dll',
                ],
            },
            ...
)
Jake Levitt
  • 120
  • 1
  • 9