Starting mapclient on Mac OS X (10.10)

Asked by Chris

Dear mapclient developers,

Today, I managed to install mapclient under Mac OS X, but it refuses to start-up and I was hoping you could point me to a possible solution. This is the output I receive when calling "mapclient" after installing it through pip as well as installing PySide 1.2.1 from the Qt project website under Mac OS X (10.10):

Traceback (most recent call last):
  File "/usr/local/bin/mapclient", line 9, in <module>
    load_entry_point('mapclient==0.11.2', 'console_scripts', 'mapclient')()
  File "/Library/Python/2.7/site-packages/pkg_resources.py", line 339, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2470, in load_entry_point
    return ep.load()
  File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2184, in load
    ['__name__'])
  File "/Library/Python/2.7/site-packages/mapclient/application.py", line 32, in <module>
    from mapclient.settings import info
  File "/Library/Python/2.7/site-packages/mapclient/settings/info.py", line 20, in <module>
    from PySide import QtCore
ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Library not loaded: QtCore.framework/Versions/4/QtCore
  Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so
  Reason: image not found

Apparently, it refuses to load QtCore, which is installed using homebrew (in /usr/local/lib). I am not sure why mapclient can not find this framework, which is placed in a pretty standard location or could this be cause by some incompatibility in versions between QtCore.so?

QtCore is installed here in my case:
/usr/local/lib/QtCore.framework/Versions/4/QtCore
And I can see your QtCore.so here
/Library/Python/2.7/site-packages/PySide/QtCore.so

I have tried to adjust LD_LIBRARY_PATH, DYLD_LIBRARY_PATH to allow mapclient to find QtCore, but it still doesn't work. Maybe you have a better idea what might be wrong?

Thanks and best regards,
Chris

Question information

Language:
English Edit question
Status:
Solved
For:
MAPClient Edit question
Assignee:
No assignee Edit question
Solved by:
Chris
Solved:
Last query:
Last reply:
Revision history for this message
Chris (ctp) said :
#1

After looking into this, it's probably fair to say that this is not something you have to fix, as the problem is caused by PySide. However, if other people run into the same problem, I can give you a quick solution for this issue. If you install PySide libraries from the Qt provided package (as I did) their dependencies to Qt are not written as a full paths. (You can check the dependencies by calling otool -L some_library.dylib). For example in this case I would look at:

otool -L PySide/QtCore.so

PySide/QtCore.so:
 libpyside-python2.7.1.2.dylib (compatibility version 1.2.0, current version 1.2.1)
 libshiboken-python2.7.1.2.dylib (compatibility version 1.2.0, current version 1.2.1)
 QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.5)
 /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

The dependency to QtCore is therefore not fully resolved and I have no idea, why it is not simply picked up from LD_LIBRARY_PATH or DYLD_LIBRARY_PATH, but it doesn't work for me. To fix it in the most easy way, I could come up with, you can actually edit these entries inside those libraries using "instal_name_tool". For example you can call:

install_name_tool -change "QtCore.framework/Versions/4/QtCore" "/usr/local/lib/QtCore.framework/Versions/4/QtCore" PySide/QtCore.so

And you then have to do this for all libraries inside the PySide folder and all the "unresolved" dependencies (to QtGui, QtNetwork, etc.)

That way I got it to run at least. If anyone has a better solution, please let me know.

Revision history for this message
Chris (ctp) said :
#2

Since this generally works for me, I can share a few lines of (python) script code to get this done for anyone else with the same issue. Note that you probably have to execute python as sudo, if PySide is installed inside a write protected directory:

sudo python >>>

#/usr/bin/python

import os
import subprocess

fix_qt_lib_path = '/Library/Python/2.7/site-packages/PySide'
fix_qt_libraries = [qt_lib for qt_lib in os.listdir(fix_qt_lib_path) if (qt_lib.startswith('Qt') and qt_lib.endswith('.so'))]

missing_path_prefix = '/usr/local/lib/'
replace_qt_lib_paths = [qt_lib[:-3] for qt_lib in fix_qt_libraries]

for qt_lib in fix_qt_libraries:
 for replace_qt_lib in replace_qt_lib_paths:
  subprocess.call(['install_name_tool', '-change', replace_qt_lib+'.framework/Versions/4/'+replace_qt_lib, missing_path_prefix+replace_qt_lib+'.framework/Versions/4/'+replace_qt_lib, os.path.join(fix_qt_lib_path,qt_lib)])

for qt_lib in fix_qt_libraries:
 subprocess.call(['otool','-L',os.path.join(fix_qt_lib_path,qt_lib)])

Best of luck !