5

With wxPython (latest) installed on OS X Lion, an attempt to import wx in the interpreter results in:

  File "wx/__init__.pyc", line 45, in <module>
  File "wx/_core.pyc", line 4, in <module>
  File "wx/_core_.pyc", line 18, in <module>
  File "wx/_core_.pyc", line 11, in __load
ImportError: /Users/Pyderman/Downloads/e30356784638/dist/Program.app/Contents/Resources/lib/python2.6/lib-dynload/wx/_core_.so: no appropriate 64-bit architecture

So following the instructions given by man python, I set:

export VERSIONER_PYTHON_PREFER_32_BIT=yes

and then the import of wx works (in the interpreter). Yet when I bundle the program into an OS X app using py2app, the error re-occurs, even though I am trying to launch the app within the same terminal where I have set the environment variable to prefer 32 bit.

I'm guessing that somehow py2app doesn't "know" that 32-bit is preferred? But how so, and how can this be enforced or controlled?

Pyderman
  • 14,809
  • 13
  • 61
  • 106
  • 1
    I found this link and it looks like it does the trick. [How to force py2app to run app in 32 bit mode](http://stackoverflow.com/questions/7472301/how-to-force-py2app-to-run-app-in-32-bit-mode) – Steve C Jan 18 '16 at 21:38
  • Thanks. Have yet to try any of the proposed solutions suggested in that post, but you can go ahead and submit an answer and I'll select it. – Pyderman Jan 19 '16 at 14:22

1 Answers1

0

Let me expand a bit on what Steve C said... The easy solution would be to install Python 32 bit only from the python website as Ned suggests here

A slightly more difficult way but maybe more efficient long term would be to set the architecture type to 32bit using something like ditto as fviktor suggests. This removes everything but the i386 architecture so it won't try to load any of those pesky 64bit versions.

Ditto source from fviktor:

ditto --rsrc --arch i386 YourApplication.app YourApplicationStripped.app

As mentioned it removes all the non 32bit "stuff" which in return lowers the package size and ensures it will never try to load a 64bit architecture.

If you wanted a 32 and 64 bit architecture available you could set the priority of the architecture to have 32bit be the primary. To do this edit Info.plist that is created by Py2App. Here you have 4 options, ppc which is 32 bit powerPC architecture, i386 (more commonly used I believe) 32bit architecture, and then two different 64bit architectures, x86_64 and ppc64.

Most of your question can be answered here but I believe it is different enough that it might help someone better understand what is happening in the future.

Community
  • 1
  • 1
Steve Byrne
  • 1,320
  • 1
  • 16
  • 29