views:

783

answers:

2

When my IronPython program gets to the line

import wx

I get this message:

A first chance exception of type
'IronPython.Runtime.Exceptions.PythonImportErrorException' occurred in IronPython.dll

Additional information: No module named _core_

although I do have the file wx\_core_.pyd. Also, before attempting the import, I have the lines:

sys.path.append('c:\\Python24\\Lib\\site-packages')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode\\wx')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode\\wx\\lib')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wx-2.6-msw-unicode\\wxpython\\lib')
sys.path.append('c:\\Python24\\Lib\\site-packages\\wxaddons')

which I hoped would let IronPython find everything it needed.

+6  A: 

No, this won't work. Wx bindings (like most other "python bindings") are actually compiled against CPython.

In this regards they are not just packages on sys.path to be found, as you have tried. They actually depend on CPython itself. This rather dry document explains the process.

Note: There was a mission by some of the crew at Resolver Systems to allow you to use CPython bindings with IronPython (called IronClad) but this is in its early stages, and I think they will concentrate on getting things like Numpy working first, GUI toolkits will always be the last, and hardest.

Ali A
Thanks. I had a feeling this was going to be the answer.
Charles Anderson
I think if you want to get cross-platform UI with IronPython, you are limited to 1. Windows Forms, 2. GTK#
Ali A
(also) 3. wx.NET
Ali A
+2  A: 

While wxPython is unavailable for the reasons listed by @Ali, you may want to take a look at wx.NET. You could use IronPython to call these assemblies instead, and it should be cross-platform (I'm assuming that's what you're after, or you would just use WinForms). If all you're looking for is API compatibility, I think you're out of luck :(

technomalogical
+1 didn't know about wx.NET
Ali A