1
votes

I am trying to convert a python script into a windows exe file. I followed the py2exe tutorial and looked at some of the samples install with py2exe and created a setup.py file that appends the appropriate VC dlls to the system path

from distutils.core import setup
import py2exe
import sys

sys.path.append("C:\\My_VC_dlls")

Then copy them into the dist folder

from glob import glob
data_files = [("Microsoft.VC90.CRT", glob(r'C:\My_VC_dlls\*.*'))]

Then pass options to setup

setup(
   options = {"py2exe": {"compressed": 1, "optimize": 2,
                         "ascii": 1, "bundle_files": 1}},
   zipfile = None,
   data_files=data_files,
   console = ['my_python.py']
)

I run setup.py py2exe and it builds the executable and it works well

I was asked about making the exe look more like a windows program, so i'm trying to do the sample singlefile/gui (installed with py2exe) that instantiates a class: Target

class Target:
    def__ Blah Blah Blah

a manifest template

manifest_templete = '''
...

and then

test_wx = Target(
     description = "....
     .....

and then basically the same setup options but with:

setup(
   options...
   ....
   windows = [test_wx]

with the appropriate changes made to the script names and such (test_wx.py --> my_python.py)

And it builds the exe but when I launch it, "This program can't start because MSVCR90.dll is missing"

My question is, it appears that the when telling py2exe that it's a console app, the built exe knows to look in dist/MICROSOFT.VC90.CRT/ for the DLL, but when telling py2exe that it is a windows app, the built exe doesn't. In short how do I make this problem go away? How do I embed the location of the DLL into the built exe?

Sorry in advance if this is a trivial question. I am total newbie to Python and windows programming.

1

1 Answers

1
votes

Have you tried calling sys.path.append("dist/MICROSOFT.VC90.../") in your app? (not setup.py)

Also how about putting vc90 dlls alongside your main executable, and not in a subdirectory.