pythonmacospyqt4pypm

Image not found error when importing QtGui from PyQt4


I have installed ActivePython 2.7 on Mac OS X 10.5. The main reason for this is to use pypm, the package manager. However, after installing ActivePython and setting up my .bash_profile file to use that version of Python, I encounter a lot of problems with the pypm-installed libraries. To install all of these modules, I just type

pypm install <package-name>

and this is how I got matplotlib, PyQt4, PIL, etc. The problem is that all of these appear to install with no problems, they place the correct .pth and .so files into the correct site-packages folder, and basic imports work fine. But I get the following errors.

First, here is what I see when checking for Python on my machine:

new-host:site-packages ely$ which python
/usr/local/bin/python

new-host:site-packages ely$ ls -l /usr/local/bin/python
lrwxr-xr-x  1 root  wheel  60 May 25 22:15 /usr/local/bin/python -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python

Next, I invoke Python and attempt to import things.

new-host:site-packages ely$ python
ActivePython 2.7.1.4 (ActiveState Software Inc.) based on
Python 2.7.1 (r271:86832, Feb  7 2011, 11:33:10) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> from PyQt4 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(PyQt4/QtGui.so, 2): Library not loaded: QtGui.framework/Versions/4/QtGui
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/PyQt4/QtGui.so
Reason: image not found

So the above shows that PyQt4 imports with no complaints, but then I get the 'image not found' error when I try to use any of the sub-modules. For another example, here is the standard matplotlib.

>>> import matplotlib
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "matplotlib/pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
File "matplotlib/figure.py", line 16, in <module>
import artist
File "matplotlib/artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "matplotlib/transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: dlopen(matplotlib/_path.so, 2): Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/matplotlib/_path.so
Expected in: dynamic lookup

>>> from matplotlib import pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "matplotlib/pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
File "matplotlib/figure.py", line 16, in <module>
import artist
File "matplotlib/artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "matplotlib/transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: dlopen(matplotlib/_path.so, 2): Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/matplotlib/_path.so
Expected in: dynamic lookup

Any thoughts on why the pypm-installed versions are so problematic? I've used ActivePython and pypm on my Ubuntu work computer for a long time and never had any of these issues. Everything I've ever installed with pypm has worked beautifully. Why is it so different on Mac?


Solution

  • Make sure python and qt have same architecture (32bit vs 64bit)

    for mathplot looks like a different g++ used to compile python and mathplot

    have you tried with stock osx python?