3

ive been trying to run an application that was written on a Linux machine (and works without any issues), on my Mac running OS X El Capitan. the program utilizes PyQt4(4.11.4) and PySide (1.2.4), using Python 3.4.2. I created a virtualenv to guarantee that everything runs on the correct version of python. i have sip installed as well. However when i actually try to import anything from PySide it gives me the following error:

Traceback (most recent call last):
  File "GUI.py", line 17, in <module>
    from PySide import QtCore, QtGui, QtNetwork
ImportError: dlopen(/Users/mksmasr/.pyenv/versions/3.4.2/envs/pubdatapy34/lib/python3.4/site-packages/PySide/QtCore.so, 2): Library not loaded: @rpath/libpyside.cpython-34m.1.2.dylib
  Referenced from: /Users/mksmasr/.pyenv/versions/3.4.2/envs/pubdatapy34/lib/python3.4/site-packages/PySide/QtCore.so
  Reason: image not found

i cant seem to figure out the issue even after reading other SO posts and trying everything suggested.

when i run python at the command line and import PySide it imports it without an issue, the problem arises when trying to access anything inside of the PySide directory.

ive installed everything from source,it didn't work, so i tried pip,same issue, then i tried homebrew, and same issue. is the issue possibly PySide and python3.x compatibility?

I would appreciate any help!

cyborg95
  • 185
  • 11
  • I'm having the same problem. Installed QT via brew, PySide via pip, had to install CMake and it's command line tools to make the latter work, now I am at the same point getting the same error. Any help would be wonderful. – Frank Rueter Jul 26 '16 at 04:43
  • Possible duplicate of [PySide / Qt Import Error](http://stackoverflow.com/questions/25656307/pyside-qt-import-error) – johnson Feb 12 '17 at 16:49

1 Answers1

5

I got it to work. First, following this thread here

This gave the option of using PySide 1.2.2 or building 1.2.4 from scratch. I settled for 1.2.2:

pip install -U PySide==1.2.2

After that, when trying to import PySide libraries, I got errors complaining about

unsafe use of relative rpath

To fix those I followed this advise

In a nutshell: I checked the libraries for relative links like this:

otool -L /Library/Python/2.7/site-packages/PySide/QtCore.so

Then I used install_name_tool -change ... as outlined in above link to re-link the two relative libraries in there to "/usr/local/...". E.g.:

sudo install_name_tool -change libshiboken-python2.7.1.2.dylib /usr/local/lib/libshiboken-python2.7.1.2.dylib QtCore.so
sudo install_name_tool -change libpyside-python2.7.1.2.dylib /usr/local/lib/libpyside-python2.7.1.2.dylib QtCore.so

Rinse and repeat for all the .so files. This got PySide 1.2.2 working on El Capitan for me.

Community
  • 1
  • 1
Frank Rueter
  • 729
  • 1
  • 10
  • 21