[CentralOH] Python, py2exe, and Windows

Mark Erbaugh mark at microenh.com
Fri Oct 29 14:17:57 CEST 2010


On Oct 29, 2010, at 4:06 AM, James - Atlantix wrote:

> I have done exhaustive searching and efforts to get a PyQt program to compile with py2exe and run under Windows 7. It simply will not. I am fine with Python 2.5, but not with Python 2.6. I have done the side by side installation of the MSVCR90.dll and a manifest file in my dist directory . . . . and followed about a dozen examples on the web. My only logical conclusion at this point is that Windows is fried and my main alternative is to distribute .pyc files along with the minimal distro of Python that I need. Windows is like the grand vision of the hallucinogenic collective, perhaps more amorphous and delicately sublime than that.
>  
> James
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh


James,

If you have to go the route of distributing .pyc files, look a the standard library zipfile.PyZipFile routine. This takes a directory, compiles the .py files to .pyo and creates a .zip file, containing just the .pyo files. In your startup code, which still needs to be outside the zip, but can be trivial, you add the zip file to sys.path. For several versions, Python  has had the ability to do import's directly from a zip file. Here's a simple script to create the zip file:

import zipfile

f = zipfile.PyZipFile(<name.zip>, 'w', Z.ZIP_DEFLATED)
for i in (<list of folders>):
    f.writepy(i)
f.close()

using this scheme, I have created a .zip file on one OS (i.e. Mac OSX) and run the application on Linux or Windows (XP, haven't tried newer). The only caveat is that the Python installed has to be of the same major version, i.e. 2.6.  For example, my Mac runs 2.6.1 and the created zip file works on Windows XP with 2.6.5, but wouldn't work with 2.5.x or 2.7.x

For slightly added security, you don't need to name the ZIP file with a .zip extension.

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20101029/ea9f0ffb/attachment.html>


More information about the CentralOH mailing list