PyQt4 is a Python binding for QT 4 based on the Sip binding generator.
The current version of PyQt installed from Macports keeps crashing Python with “Bus Error” when importing QtWebKit module. Any other module from PyQt works just fine, except for QtWebKit.
To install PyQt, we need the following 4 ports:
Digging into the portfiles, I could see that the ports py25-pyqt4 and py25-sip are outdated, referring to version 4.4.3 and 4.7.6 respectively. Luckily, installing PyQt 4.4.4 and Sip 4.7.9 from source is enough to solve the problem, but if you like to keep your stuff organized with Macports, you will need to update your portfiles. Here is the recipe:
First, you have to install Python from Macports and set it up with python_select.
#Install python from Macport sudo port install python25 #install python_select to avoid mixing stuff with Apple's Python sudo port install python_select #set macports python as the default sudo python_select python25
Then you need to patch your portfiles. Save the bellow patches to your disk and apply them.
Port-py25-pyqt4.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/python/py25-pyqt4/Portfile 2008-12-23 19:52:30.000000000 -0200
+++ /Users/henrique/Portfile.py25-pyqt4 2009-02-11 10:23:08.000000000 -0200
@@ -3,7 +3,7 @@
PortSystem 1.0
name py25-pyqt4
-version 4.4.3
+version 4.4.4
revision 1
platforms macosx
categories python devel
@@ -19,14 +19,10 @@
http://pyqwt.sourceforge.net/support/
distname PyQt-mac-gpl-${version}
-checksums md5 6d2a11cd1372ce98b486e9bc5de3c0fc \
- sha1 6d1f3a717e551cd762b0adbd9c50f213c3ce8cbe \
- rmd160 da91bedccfb6b1e3cbc69f527dd57ead83eb647e
+checksums md5 b4fc6142bec4dc75facf7c9a8b556c1f
depends_lib port:py25-sip port:qt4-mac
-#patchfiles patch-configure.py
-
set qt_dir ${prefix}/libexec/qt4-mac
pre-configure {
Port-py25-sip.diff
--- Portfile 2008-06-29 19:30:43.000000000 -0300
+++ /Users/henrique/Portfile.py25-sip 2009-02-10 20:39:12.000000000 -0200
@@ -3,7 +3,7 @@
PortSystem 1.0
name py25-sip
-version 4.7.6
+version 4.7.9
platforms macosx
categories python devel
maintainers saispo@macports.org
@@ -22,15 +22,11 @@
http://www.gtlib.gatech.edu/pub/gentoo/distfiles/
distname sip-${version}
-checksums md5 f49e93046fe438a8fb4c2ed481aa3951 \
- sha1 8ae089513744c394e502e258b428780260e39cda \
- rmd160 bc3b9668afc9f3c4e475ccd9a89d1b270ad5d0ba
+checksums md5 597d7ff7edb42a18421c806ffd18a136
dist_subdir python
depends_lib port:python25
-patchfiles patch-siputils.py.diff
-
configure.cmd ${prefix}/bin/python2.5 configure.py
configure.pre_args -d ${prefix}/lib/python2.5/site-packages \
-e ${prefix}/include/python2.5 \
Now that you have the patches, just apply them and install the modified ports:
sudo patch /opt/local/var/macports/sources/rsync.macports.org/release/ports/python/py25-sip/Portfile Port-py25-sip.diff sudo patch /opt/local/var/macports/sources/rsync.macports.org/release/ports/python/py25-pyqt4/Portfile Port-py25-pyqt4.diff sudo port install py25-sip sudo port install py25-pyqt4
To verify that everything works fine, start the Python interpreter and import the module:
from PyQt4 import QtWebKit







