From: Pierre Z. <Pie...@ps...> - 2006-01-23 14:12:58
|
Hi all, I have been using Python for .Net (http://www.zope.org/Members/Brian/PythonNet/) to create a GUI for my python code. When it came time to pack the code into an exe, running py2exe raised the following warnings: "The following modules appear to be missing ['CLR.System.Drawing', 'CLR.System.Windows.Forms']" The .exe was created, though, but running it immediately raised an error: "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Additional information: Could not load file or assembly 'Python.Runtime, Version=3D1.0.0.0, Culture=3Dneutral, PublicKeyToken=3Dnull' or one of it= s dependencies. The system cannot find the file specified." This error is resolved by placing the file "Python.Runtime.dll" into the dist folder just created. Running the .exe then raised another error: "Traceback (most recent call last): File "convertForm.py", line 6, in ? ImportError: No module named System.Windows.Forms" The code in question featured the following imports to handle the importation of the requisite dotnet modules: "import CLR.System.Windows.Forms as WinForms from CLR.System.Drawing import Size, Point" As the traceback made clear, py2exe wasn't resolving the (implicit) importation of the requisite dotnet dlls. All that was needed to rectify this, however, was to add an explicit import of the CLR namespace on its own line immediately preceding the other two imports: "import CLR import CLR.System.Windows.Forms as WinForms from CLR.System.Drawing import Size, Point" Now everything is working fine. It still raises that first warning but this can be ignored. I hope this helps someone else, Pierre Notice This email is intended for the addressee only and may contain legally pri= vileged and/or confidential information. If you have received this email= in error and are not the intended recipient, you are hereby informed tha= t you are not entitled to read, broadcast, distribute or in any manner wh= atsoever use the contents of this email or any attachments thereto. You = are requested to please notify Psitek that you have received the email an= d then delete it. Unless clearly stated otherwise, the content and senti= ments expressed in this email or any attachments thereto are those of the= sender and not of Psitek (Proprietary) Limited. Psitek does not accept = liability for any damages, loss or expense of any nature whatsoever arisi= ng (a) out of or in connection with the email or any attachments thereto = and/or (b) from any act or omission by the recipient relying upon the con= tent of the email or attachments. Psitek further disclaims liability for= any damages caused by computer and/or software viruses. Should this ema= il contain the terms of a contract, no binding agreement will result unti= l such time as a written (hardcopy) document is signed on behalf of Psite= k. |