2

So, I've got a program I made in python 2.6, it ran fine as normal python, and ran fine when made into an exe via py2exe v0.6.9. I used signtool to sign it, having changed nothing else, and it stops working.

When I run the signed exe, I receive an "ImportError: No module named os" from line 1 of my script. I did some digging and found this: http://osdir.com/ml/python.py2exe/2008-04/msg00031.html, which seems to be a very close description of my problem. I manually applied the patch linked to from the py2exe website to my build_exe.py file, though I was running py2exe 0.6.9 instead of 0.6.6, so I tried to take that into account. Still no love.

According to the link, this seems to be a py2exe issue. I don't know though. Any help would be much appreciated. And of course, I'll answer any other questions I can that you have about this. Thanks for the help!

nixjdm
  • 121
  • 1
  • 11
  • 2
    The solution is below (not using py2exe!). The problem is that py2exe expects a ZIP archive containing the included modules at the end of the executable. `signtool.exe` adds some more data to the end of the file, so py2exe fails to read the archive and therefore can't import any module. – leoluk Aug 26 '11 at 02:18
  • That makes perfect sense, thanks for the explanation. – nixjdm Aug 28 '11 at 03:11

1 Answers1

2

If it's a py2exe issue, maybe give the newer PyInstaller a shot to build your executable. It's in active development, unlike py2exe which apparently hasn't been updated since 2008-11-16.

wim
  • 338,267
  • 99
  • 616
  • 750
  • PyInstaller seems pretty nice, but I haven't got it to work with this program yet because it uses PySide. What other packaging systems produce exes that can be signed, even better if they are known to work with pyside well? Is cx_freeze safe? – nixjdm Aug 28 '11 at 03:11
  • @Joe, I've used cx_freeze. It's very simple to use, but I can't promise that it works with PySide. What do you mean, is it safe? – Velociraptors Aug 29 '11 at 18:27
  • @Velociraptors, I meant, can I sign exes made with cx_freeze, and have them still work? – nixjdm Aug 29 '11 at 21:10
  • I was mistaken with where I was having the PyInstaller trouble before, PySide had nothing to do with it and was in fact incorporated seamlessly. Problem solved. – nixjdm Aug 30 '11 at 04:11