[Python.NET] Fwd: A question about pythonnet + pyinstaller

Jeremy Chiu greenhat at gmail.com
Tue Apr 30 18:50:50 CEST 2013


Hi All,

  So, the issue I'm running into is in combining pyinstaller with
pythonnet.  I'll describe my current situation.  Hopefully it isn't too
long and you have some insight.

  I have a little bit of UI put together via Windows forms.  I can run it
fine via pythonnet by doing "clr.AddReference('System.Windows.Forms')" to
load the assembly, doing "from System.Windows.Forms import Application" to
get at the Application class so I can do Application.Run(myform), and by
adding the location of my little UI dll to the python path and importing
classes I need from there.

  I can also happily do all this after building everything into an exe via
pyinstaller.  I did have to jump thru a few pyinstaller hoops to add my
little dll to the package pyinstaller builds as well as Python.Runtime.dll.
 The path to the location where those are added is appended to pythonpath
auto-magically by pyinstaller so they're found just fine.

  So then I found that I needed to get at System.ComponentModel.BindingList
and System.Drawing.Bitmap.  I thought all I'd have to do would be
"clr.AddReference('System')" and "clr.AddReference('System.Drawing')" and
then import BindingList from System.ComponentModel and Bitmap from
System.Drawing.  This worked fine when running from pure python but was
unhappy running from the pyinstaller-built exe.  In the exe it complains
that it can't import BindingList (or Bitmap if I comment out BindingList).
 I can make it work in the exe if I use a direct import instead of a 'from'
style import.  So if I do "import System.ComponentModel.BindingList"
instead of "from System.ComponentModel import BindingList" it works.
 However I don't think I should have to do a direct import and doing so
gives me problems in the pure python world.

  I actually don't even understand how the System.Windows.Forms assembly is
found in the exe scenario.  I don't add the System.Windows.Forms.dll to the
package that pyinstaller builds and yet it works just fine which implies
that it is being found elsewhere but I don't understand how (nor why it
doesn't find the other assemblies that I also want).

  Sorry for the long email.  Hopefully you have some insight.  Hopefully
you know what pyinstaller is so that the majority of this email makes some
sense =p

Thanks for any leads you can provide,
Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20130430/d6df0de8/attachment.html>


More information about the PythonDotNet mailing list