views:

396

answers:

4

Hi,

I created little app for sending out emails when something is wrong with server. Used py2exe to create exe file. While it is works absolutely fine on Win7 i have problems with running it on WinSRV2003. I do not believe that it has something to do with code itself. Please see imports below

import pyodbc, sys, smtplib, os
from datetime import date
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
import email.iterators
import email.generator

setup.py file:

from distutils.core import setup
import py2exe
import modulefinder

modulefinder.AddPackagePath("mail.mime", "base")
modulefinder.AddPackagePath("mail.mime", "multipart")
modulefinder.AddPackagePath("mail.mime", "nonmultipart")
modulefinder.AddPackagePath("mail.mime", "audio")
modulefinder.AddPackagePath("mail.mime", "image")
modulefinder.AddPackagePath("mail.mime", "message")
modulefinder.AddPackagePath("mail.mime", "application")

setup(console=['capfile_tester.py'],
    options = { "py2exe": { "includes": "decimal, datetime, email" } })

And also one line from py2exe output that might be interesting

The following modules appear to be missing ['_scproxy']

Error message when trying to start it:

This application has failed to start because application configuration is incorrect. Reinstalling the application may fix this problem.

What came to my mind is could it missing some registry keys taht would allow app to run?

A: 

I'd say this is a missing DLL's problem. You should check and see the DLL's your application bundles ( or presumes to exist on the target computer ). I think you can do that with the depends.exe that comes with Visual Studio.

EDIT: I just remembered. Make sure you run py2exe with a Python 2.5 installation. The 2.6 had some bugs and that made the exe not work on several machines.

Geo
Nice hint, i thought it may have something to do wtih architecture but when i created exe on virtual xp 32bit it still would not work on server 2003.I still need to check dll dependencies.
MichalKlich
I had the same problem you had. I wrote a script that used PIL, and on several machines it didn't work. Turns out it was because of a DLL problem. Also, make sure you compile using python 2.5 and not python 2.6. It's very important !
Geo
A: 

A search on _scproxy seems to indicate that _scproxy is a new module in 2.6. Perhaps somehow Python 2.5 is involved? py2exe is supposed to make a completely self-contained executable, so I don't see how that's possible, though.

Another possibility is that _scproxy depends on a dll that isn't available in Windows 2003? Have you tried running your program without py2exe on Win2003?

Ned Batchelder
Unfortunately they might not let me install python on server but i`ll ask. Thanks.
MichalKlich
A: 

Googling for your "this application has failed to start..." message suggests strongly this is a DLL problem, probably with msvcp80.dll and friends. This is a very common occurrence with recent Windows/Python/py2exe given how MS keeps changing MSVCC libraries etc. Different Python versions are linked with different libraries and if they aren't pre-installed on your target machine you can get problems like this. Sometimes installing the appropriate redistributable package from MS works.

Note that the py2exe warnings, in this case about _scproxy, can almost always be ignored. It's very common to get what amount to spurious reports of missing modules like that. 95% of the time we can ignore them, even when we see literally dozens of modules "missing".

Peter Hansen
A: 

I had a similar problem where COM objects were involved. Maybe that's the case here, too. This description solved my problems. My software would then run on different Windows versions, which it before would not.

Bertolt