6

I created an executable with py2exe on a 64bit windows 7 machine, and distributed the program.

On a windows xp 32bit machine the program refuses to run exhibiting the following behavior:

a popup window says: program.exe is not a valid win32 application.

The command prompt window says "access denied"

I checked for permissions and the user has full control and complete ownership of the file and its parent directories. So that can't be the issue.

The only feasible possibility I can image is an OS/architectural incompatibility. How should I fix this?

My setup.py file used to generate the executable:

from distutils.core import setup
import py2exe

setup(console=['xerxes2excel.py'])

I ran the following to generate the exe:

python setup.py py2exe
Razor Storm
  • 12,167
  • 20
  • 88
  • 148
  • Try creating the executable using a 32bit machine – inspectorG4dget Jun 16 '11 at 21:15
  • wouldn't it be safe to say you probably created a 64-bit executable, which won't run on a 32-bit processor? – jcomeau_ictx Jun 16 '11 at 21:16
  • @jcomeau_ictx, that's my assumption. Is there a way to create a 32bit executable on a 64bit machine? Through some sort of emulation magicks? – Razor Storm Jun 16 '11 at 21:17
  • there might be, but you'll be more likely to get an answer if you change your question to what you just asked me. I personally haven't used py2exe – jcomeau_ictx Jun 16 '11 at 21:19
  • Windows 7 - run `py2exe` and the `cmd` session in compatibility. Perhaps that will helps – inspectorG4dget Jun 16 '11 at 21:31
  • try to produce the executable on a virtual machine with windowsXP and python 32 bit running on it – joaquin Jun 16 '11 at 21:46
  • Turns out the only incompatibility was the python interpreter. I installed a 32bit python and 32 bit versions of all the modules I used and it works now. There's still problems, but that's a different issue. Thanks guys – Razor Storm Jun 16 '11 at 21:55

2 Answers2

7

I think you just need to install 32-bit python and 32-bit py2exe on your machine.... see Can 64-bit python create 32-bit Windows executables

Community
  • 1
  • 1
bwawok
  • 14,898
  • 7
  • 32
  • 43
4

A common problem when you generate executable on Windows 7 and deploy on Windows XP.

According with the py2exe tutorial, you need include the MVC DLL. But the tutorial is old and the script given search only in one directory. Before, the directory contained all DLL and the manifest, but nowadays it contains only the DLL. You need to specify another directory for the manifest file. If you don't do that, you will have this kind of error:

this application has failed to start because the application configuration is incorrect

If you are on Windows 7 64 bits, you need the Microsoft Visual C runtime DLL. Don't forget the manifest that isn't in the same directory in Windows 7. You need to adapt the script like this:

data_files = [("VC90", glob(r'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\*.*')),
            ("VC90", glob(r'C:\Windows\winsxs\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest'))
]
setup(
    data_files=data_files,
    console = [{'script': "C:\test\my_program.py"}],
    zipfile = None,
)

Now you can deploy the "dist" directory that contains all files and dependencies.

Gagou
  • 41
  • 2