どうも Mac OS X El Capitan では System Integrity Protection(SIP) という新しいセキュリティー機能が原因で、NAOqi Python SDK が使えないようです。
こんな感じでエラーが出てきたら、それは SIP によるセキュリティー機能によるものです。
>>> import naoqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tkawata/naoqi/pynaoqi-python2.7-2.4.2.26-mac64/naoqi.py", line 9, in <module>
import qi
File "/Users/tkawata/naoqi/pynaoqi-python2.7-2.4.2.26-mac64/qi/__init__.py", line 66, in <module>
from _qi import Application as _Application
ImportError: dlopen(/Users/tkawata/naoqi/pynaoqi-python2.7-2.4.2.26-mac64/_qi.so, 2): Library not loaded: libboost_python.dylib
Referenced from: /Users/tkawata/naoqi/pynaoqi-python2.7-2.4.2.26-mac64/_qi.so
Reason: unsafe use of relative rpath libboost_python.dylib in /Users/tkawata/naoqi/pynaoqi-python2.7-2.4.2.26-mac64/_qi.so with restricted binary
>>>
SDK が参照しているライブラリーの参照方法が問題のようで、正式には SDK が修正されるのを待つしかありません。(各 NAOqi 2.4.2 SDK は Mac は現状 Yosemite がサポート OSです)
暫定的な対応になりますが、パッチを当てるスクリプトを作ってみました。
patch_naoqi_python_sdk_for_elcaptain.sh
#!/bin/bash
if [ $# -ne 1 ]; then
echo "パラメータエラー" 1>&2
echo "sh patch_naoqi_python_sdk_for_elcaptain.sh naoqi_python_sdkのパス"
exit 1
fi
NAOQIDIR=$1 # "${HOME}/naoqi/pynaoqi-python2.7-2.4.2.26-mac64"
if [ ! -e ${NAOQIDIR}/naoqi.py ]; then
echo "指定されたパスは naoqi python SDK ではないようです"
exit 1
fi
cd ${NAOQIDIR}
for file in `ls *.dylib *.so`
do
# patch all library internal cross references
echo "Patching " $file "..."
for fileother in `ls *.dylib *.so ;ls qi *.dylib *.so`
do
# library
echo " Patching " $fileother " with " $file "..."
install_name_tool -change $file $NAOQIDIR/$file $fileother
done
# patch Python reference for the library
install_name_tool -change /Library/Frameworks/Python.framework/Versions/2.7/Python /System/Library/Frameworks/Python.framework/Versions/2.7/Python $file
done
for file in `ls *.dylib *.so`
do
# patch all library internal cross references
echo "Patching " $file "..."
fileother="qi/plugins/libqimodule_python_plugin.dylib"
# library
echo " Patching " $fileother " with " $file "..."
install_name_tool -change $file $NAOQIDIR/$file $fileother
# patch Python reference for the library
install_name_tool -change /Library/Frameworks/Python.framework/Versions/2.7/Python /System/Library/Frameworks/Python.framework/Versions/2.7/Python $file
done
パラメータで NAOqi SDK のパスを指定します
sh patch_naoqi_python_sdk_for_elcaptain.sh PythonNAOqiSDKのパス