The problem is that WxPython is only available on the Mac in 32-bit mode; however, by default, Python will start up in 64-bit mode. To fix this problem, create the following shell script named python2.6_32
:
#! /bin/bash export VERSIONER_PYTHON_PREFER_32_BIT=yes /usr/bin/python2.6 "@"
Make the script executable (chmod a+x python2.6_32
) and place the script in your path. Now, simply invoke python2.6_32
to get an interactive Python console in which you can use WxPython. If you want to write a Python script that uses this, you can use the shebang: #! /usr/bin/env python2.6_32
.
Now to explain... the basic problem is that 32-bit and 64-bit code uses a different application binary interface (ABI), and so 32-bit code and 64-bit code cannot coexist in the same library/executable/process. In order to support 64-bit mode, it needs to have been compiled in 64-bit mode; likewise, to support 32-bit mode, it needs to have been compiled in 32-bit mode. Under OS X, it is possible, using universal binaries to support both... however, it needs to be compiled in both modes (and then merged). WxWidgets probably uses Carbon, which is only available in 32-bit mode (Cocoa is available in both 32-bit and 64-bit mode... Apple didn't bother making Carbon available in both modes, since it is being deprecated), which would explain why WxPython, in turn, could only be provided in 32-bit mode. This, in turn, means that using it in Python requires you to launch Python in 32-bit mode (Python is a universal binary with both 32-bit and 64-bit versions of itself available in the same binary file, so it can be launched in either mode).
Alternative Option
I don't recommend doing this, because I think you should leave the defaults as they are, but since you might not have enough shell scripting knowledge (you need to use "./python2.6_32" or place it in a folder that is listed in your "$PATH" environment variable and invoke it as "python2.6_32") to follow the former option, you might want to simply execute the following command which will make 32-bit mode the default:
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
If you decide you want to switch back into 64-bit mode, you can then use the following command:
defaults write com.apple.versioner.python Prefer-32-Bit -bool no
Note that both commands are to be executed on the Terminal (not within Python).
Source
I should point out that both recomendations are based on man python on Mac OS X. So, if you have any other questions, you should definitely read the man page as the error message has urged you to do.