8

I've just bought a new computer with Lion on it. I've downloaded and installed both Python 2.7 and wxPython 2.8 (for 2.7). I know Python comes with the system, but I rather go with the official one.

Anyway, upon typing "import wx" on the IDLE, I get the following message:

Traceback (most recent call last): File "", line 1, in import wx File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/init.py", line 45, in from wx._core import * File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/_core.py", line 4, in import core ImportError: dlopen(/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/core.so, 2): no suitable image found. Did find: /usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx/core.so: no matching architecture in universal wrapper

I believe it happens because wxPython only supports 32-bit, but I can't figure out how to force python to run on 32-bit.

Anyone could help? Thank you in advance.

Jajajayja
  • 185
  • 3
  • 13
  • This might help: http://stackoverflow.com/questions/2088569/how-do-i-force-python-to-be-32-bit-on-snow-leopard-and-other-32-bit-64-bit-questi – Ed L Aug 04 '11 at 18:21

4 Answers4

7

wxPython 2.9 supports 64-bit on Mac too (see the Development version section and look for the cocoa build: http://wxpython.org/download.php). This was also discussed on the mailing list, and multiple users confirmed that wx works on Lion: https://groups.google.com/forum/#!searchin/wxpython-users/lion/wxpython-users/LvjSVqqMMpQ/U0QJXEeBpLQJ

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88
  • To clarify, wxpython 2.9 is stable for general use. It's called the "development" version because there may be API changes between 2.9.x and 2.9.y so moving between those could require changing code. – Velociraptors Aug 05 '11 at 21:29
  • 1
    Yeah, 2.9 is stable. I should have mentioned that. Of course, some minor things have already changed or been deprecated, so be sure to read the changelogs. – Mike Driscoll Aug 08 '11 at 13:17
  • I tried this, but it didn't work the first time, because I forgot to uninstall another install of wxPython, as described [here](http://stackoverflow.com/questions/5920764/how-to-uninstall-wxpython-2-8-on-mac-osx-10-6). Once I uninstalled wxWidgets 2.8, and then used MacPorts to install py27-wxpython-devel, everything worked fine. – Jabavu Adams Jan 07 '13 at 20:00
1

This may not work for python versions below 2.9. Running 'python' did not work for me...I am using 2.7 for compatibility. But figured out that 'python' may be an alias for a 64 bit mode and for some reason the arch command does not work.

So, here is what I have to use under Lion to get wx to work (this works for 2.6 or 2.7):

$ arch -i386 python2.7

Then when python loads:

import wx

works fine. You may have to call the specific python with the arch command, such as python2.7, or whatever version you are using.

KurtR
  • 11
  • 1
0

You can force python to run in 32-bit mode by adding the following line to your shell profile

export VERSIONER_PYTHON_PREFER_32_BIT=yes
pastephens
  • 399
  • 3
  • 5
0

This should start it up in 32-bit mode, I'm not sure if it will fix the wx problem

% arch -i386 python                                                                                                                     
Ed L
  • 1,947
  • 2
  • 17
  • 30