yingjerkao / uni10

Official Repo for Uni10
28 stars 9 forks source link

Python bundle for OS X not finding "libpython2.7.dylib" #4

Closed Meligordman closed 7 years ago

Meligordman commented 8 years ago

Hi,

I installed the pyUni10 on a MacBook pro with OS X 10.11.5, but couldn't succeed in running the tests at first. When running any of the tests, for instance egB1.py, I got the following error.

Traceback (most recent call last): File "egB1.py", line 2, in import pyUni10 as uni10 File "/Library/Python/2.7/site-packages/pyUni10/init.py", line 1, in from .pyUni10 import * File "/Library/Python/2.7/site-packages/pyUni10/pyUni10.py", line 28, in _pyUni10 = swig_import_helper() File "/Library/Python/2.7/site-packages/pyUni10/pyUni10.py", line 24, in swig_import_helper _mod = imp.load_module('_pyUni10', fp, pathname, description) ImportError: dlopen(/Library/Python/2.7/site-packages/pyUni10/_pyUni10.so, 2): Library not loaded: @loader_path/../../../libpython2.7.dylib Referenced from: /Library/Python/2.7/site-packages/pyUni10/_pyUni10.so Reason: image not found

Looking around, it seems that the "@loader_path" is some kind of Apple variable that works with their Frameworks, but may cause trouble for standalone libraries. A user-level solution that managed to work for me was go into the /Library//Library/Python/2.7/site-packages/pyUni10/ folder and executing the command

sudo install_name_tool -change "@loader_path/../../../libpython2.7.dylib" "/usr/lib/libpython2.7.dylib" _pyUni10.so

Which basically explicitly locates python library in the system.

pcchen commented 8 years ago

Try to set the python library with cmake? For example, I have anaconda python installed in my user directory (OS X 10.11.5) and I have created a virtual environment py2k. I would do the following to compile the python wrapper:

cmake .. -DBUILD_PYTHON_WRAPPER=on -DPYTHON_INCLUDE_DIR=/Users/pcchen/anaconda/envs/py2k/include/python2.7 -DPYTHON_LIBRARY=/Users/pcchen/anaconda/envs/py2k/lib/libpython2.7.dylib