Thursday, 7 July 2016

Wxpython not found! issue on mac and Install wxPython 2.8 (For Ride) on OSX “El Capitan”

MacOS 10.8 has a new "feature" called GateKeeper which, on it's default setting, prevents installation / running of unsigned packages / apps.

All of the wxPython packages available from http://www.wxpython.org/download.php fall foul of this; when the user double-clicks on an installer package he gets a dialog:
"“wxPython2.9-osx-cocoa-py2.7.pkg” is damaged and can’t be opened. You should eject the disk image."

And using the spctl tool:
$ spctl -a -v -t install /Volumes/wxPython2.9-osx-2.9.4.0-cocoa-py2.7/wxPython2.9-osx-cocoa-py2.7.pkg
/Volumes/wxPython2.9-osx-2.9.4.0-cocoa-py2.7/wxPython2.9-osx-cocoa-py2.7.pkg: bundle format unrecognized, invalid, or unsuitable

Also I faced some other error like "Wxpython not found!"  issue on mac.
I ran into the same error:


$ sudo installer -pkg /Volumes/wxPython2.9-osx-2.9.5.0-cocoa-py2.7/wxPython2.9-osx-cocoa-py2.7.pkg/ -target /
installer: Package name is wxPython2.9-osx-cocoa-py2.7
installer: Installing at base path /
2015-10-19 11:27:48.417 installer[875:22541] Package /Volumes/wxPython2.9-osx-2.9.5.0-cocoa-py2.7/wxPython2.9-osx-cocoa-py2.7.pkg uses a deprecated pre-10.2 format (or uses a newer format but is invalid).
installer: The install failed (The Installer could not install the software because there was no software found to install.)



As you may know, on OS X, RIDE supports both wxPython 2.8 and 2.9, and that's why I'm using v2.9 here:

try:
    import wxversion
    from wxversion import VersionError
    if sys.platform == 'darwin': # CAN NOT IMPORT IS_MAC AS THERE IS A wx IMPORT
        wxversion.select(['2.8', '2.9'])
    else:
        wxversion.select('2.8')
except ImportError:
    print "wxPython not found."




Although wxmac formula can be used to install wxPython 2.9.5.0, but on OS X 10.11 El Capitan, you'll encounter the following error reported in #16329 while building wxWidgets.
So, we have to build it from (modified) source code:

So please follow the below procedure. it might work for you.

  1. Install Xcode, and download wxPython-src-2.9.5.0.tar.bz2.
  2. Extract the tarball and replace #include <WebKit/WebKit.h> (in src/osx/webview_webkit.mm) with #include <WebKit/WebKitLegacy.h>.
Then follow the instructions described in wxmac formula to build and install wxPython:
provide proper path for prefix where python is installed.
$ cd wxPython-src-2.9.5.0
$ PREFIX=/usr/local
$ ./configure --prefix=$PREFIX --enable-shared --enable-monolithic --enable-unicode --enable-std_string --enable-display --with-opengl --with-osx_cocoa --with-libjpeg --with-libtiff --with-libpng --with-zlib --enable-dnd --enable-clipboard --enable-webkit --enable-svg --with-expat --with-macosx-version-min=10.11 --enable-universal_binary=i386,x86_64 --disable-precomp-headers
$ sudo make install

$ cd wxPython
$ sudo python setup.py build_ext WXPORT=osx_cocoa WX_CONFIG=$PREFIX/bin/wx-config UNICODE=1 INSTALL_MULTIVERSION=1 BUILD_GLCANVAS=1 BUILD_GIZMOS=1 BUILD_STC=1

$ sudo python setup.py install WXPORT=osx_cocoa WX_CONFIG=$PREFIX/bin/wx-config UNICODE=1 INSTALL_MULTIVERSION=1 BUILD_GLCANVAS=1 BUILD_GIZMOS=1 BUILD_STC=1

To verify the installation:

$ python
>>> import wx
>>>

Note that this is a 64-bit setup, you don't have to run RIDE in 32-bit mode.