tags:

views:

52

answers:

1
from distutils.core import setup
import py2exe,sys,os

sys.argv.append('py2exe')

try:
        setup(
   options = {'py2exe': {'bundle_files': 1}}, 
   console=['my_console_script.py'], 
   zipfile = None,
   )
except Exception, e:
 print e

outputs:

> running py2exe
> *** searching for required modules ***
> *** parsing results ***
> *** finding dlls needed *** Traceback (most recent call last):   File
> "C:\scripts\download_ghost_recon\setup.py",
> line 26, in <module>
>     zipfile = None,   File "C:\Python26\lib\distutils\core.py",
> line 162, in setup
>     raise SystemExit, error SystemExit: error: MSVCR80.dll: No
> such file or directory

I'm on python 2.6 in Windows 7

So how can I make this MSVCR80.dll error go away, and compile my script?

On other scripts, I can run the same setup.py and not receive this error.

This makes me think that in this script, py2exe needs this MSVCR80.dll

I also tried this code, which I found here: http://www.py2exe.org/index.cgi/OverridingCriteraForIncludingDlls but it also didn't work.

from distutils.core import setup
import py2exe,sys,os

origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
        if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"):
                return 0
        return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

sys.argv.append('py2exe')

try:
        setup(
            options = {'py2exe': {'bundle_files': 1}}, 
            console=['my_console_script.py'], 
            zipfile = None,
            )
except Exception, e:
    print e

*EDIT I've also run a search on my computer for this file, it is found in these locations:

C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.762_none_10b2f55f9bffb8f8
C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_d08d7da0442a985d
C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442db5b5
+1  A: 

Append to your call to setup:

{ 'py2exe': { ...,
              'dll_excludes': [ 'msvcr80.dll', 'msvcp80.dll',
                                'msvcr80d.dll', 'msvcp80d.dll',
                                'powrprof.dll', 'mswsock.dll' ] }, ...

If you want to include the visual C runtime DLLs in your application, have a look at Microsoft's distributable runtime downloads. Probably you're using a library or module that is imported in this application, but not the others you speak of. It may be a good idea to check if you can recompile them using Visual Studio 2008, because that's what is used to create the standard Python 2.6 Windows builds.

Ivo
I"m confused.. you want me to include these files, but in the code you have written 'dll_exludes'. Anyways, it did compile with no errors this time, but when I launch the compiled script it errors and flashes quickly before I can see error message.
russo
You have to tell py2exe to not copy these files, and then, later on, you can copy them yourself. The fact that the application quickly vanishes, is because the application can't find the DLLs it needs. Have a look at the redistributable runtime downloads here: http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE and copy these DLLs to your application's directory. You may want to do the same for the VS2008 runtime libraries.
Ivo
Oh so you mean copy them after the script is already compiled and put them in the same directory as the compiled application? Is there a way I can do it so in the end all I need is one EXE to run the program? I was trying to end up with a single exe to run the prog.
russo
Correct. Unfortunately, there's only two ways to go about this: 1. include the DLLs from Microsoft in your application's directory, or 2. let the user install these DLLs system-wide (as a side-by-side assembly, Microsoft offers downloads for these that you can send your users to). Depending on your requirements, choose a solution. We chose to go with the first one, and we do not ship a single .exe but an installer that unpacks tons of files, including these DLLs.
Ivo