Using NAOqi 2.4.2 Python SDK on Mac OS X El Capitan

Apparently Mac OS X El Capitan can't use the NAOqi Python SDK due to a new security feature called System Integrity Protection (SIP).

If you get an error like this, it's due to the security features provided by 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
>>> 

There seems to be a problem with how the library referenced by the SDK is referenced, and I have to wait for the SDK to be officially fixed. (Each NAOqi 2.4.2 SDK is currently supported by Yosemite on Mac)

It's a temporary response, but I made a script to apply the patch.

patch_naoqi_python_sdk_for_elcaptain.sh


#!/bin/bash

if [ $# -ne 1 ]; then
  echo "Parameter error" 1>&2
  echo "sh patch_naoqi_python_sdk_for_elcaptain.sh  naoqi_python_sdk path" 
  exit 1
fi

NAOQIDIR=$1 # "${HOME}/naoqi/pynaoqi-python2.7-2.4.2.26-mac64"

if [ ! -e ${NAOQIDIR}/naoqi.py ]; then
	echo "The specified path doesn't seem to be the 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

Specify the path of NAOqi SDK in the parameter

sh patch_naoqi_python_sdk_for_elcaptain.sh Python NAOqi SDK path

Recommended Posts

Using NAOqi 2.4.2 Python SDK on Mac OS X El Capitan
Install python3 on Mac (El Capitan)
Using multiple versions of Python on Mac OS X (2) Usage
Install matplotlib on OS X El Capitan
When import tkinter is not possible on Mac OS X 10.11.3 (El Capitan) + pyenv + Python 3.5.1.
Using multiple versions of Python on Mac OS X (1) Multiple Ver installation
Run Zookeeper x python (kazoo) on Mac OS X
Installing TensorFlow 0.11.0rc2 on OS X El Capitan (10.11.6)
Shpinx (Python documentation builder) on Mac OS X
Memo on Mac OS X
Try using E-Cell 4 on Windows 7 or Mac OS X
Build a Python development environment on Mac OS X
[2015/11/19] How to register a service locally using the python SDK on naoqi os
Run Qiita API v2 Python wrapper in Python3 environment (Mac OS X 10.11 (El Capitan))
Install Sphinx on Mac OS X
Build a python data analysis environment on Mac (El Capitan)
Install mitmproxy on Mac OS X
Build a python environment with pyenv (OS X El Capitan 10.11.3)
Install pgmagick on Mac OS X 10.9
I installed Caffe so that I can do deep learning on MAC OS X El Capitan
How to rebuild python environment from pyenv on Mac environment (El Capitan)
Get started with the Python framework Django on Mac OS X
Continuation ・ Notes on preparing the Python development environment on Mac OS X
Install lp_solve on Mac OS X and call it with python.
How to install Theano on Mac OS X 10.10 (using pyenv, anaconda)
Installed aws-cli On Mac OS X Lion
How to erase Python 2.x on Mac.
Video processing using Python + OpenCV on Mac
Run NASA CEA on Mac OS X
python on mac
Build an environment with pyenv, pyenv-virtualenv, jupyter on OS X El Capitan
Notes on setting pyenv and python environment using Homebrew on Mac OS Marvericks
Put Python 2.7.x on Mac OSX 10.15.5 with pyenv
R environment construction with Jupyter (formerly IPython notebook) (on OS X El Capitan 10.11.3)
Install Python on Mac
Install Python 3 on Mac
Install Python 3.4 on Mac
Preparing to use aws cli on Mac OS X
Building an environment for "Tello_Video" on Mac OS X
Build a machine learning Python environment on Mac OS
Very easy to install SciPy on Mac OS X
Instructions for installing CUDA 7.5 on Mac (El Capitan) + Homebrew
Build a Python environment on your Mac using pyenv
mac OS X 10.15.x pyenv Python If you can't install
Install PyQt5 with homebrew on Mac OS X Marvericks (10.9.2)
Minimum memo when using Python on Mac (pyenv edition)
Create a Python development environment on OS X Lion
pangolin x python x mac os build failed memorandum unsolved
Minimum notes when using Python on Mac (Homebrew edition)
Steps to use the AWS command line interface (Python / awscli) on Mac OS X
I learned MNIST with Caffe and tried to draw it (MAC OS X El Capitan)
Install pygame on python3.4 on mac
Building a Python environment on a Mac and using Jupyter lab
Put Python 3.x on Ubuntu
Test Python with Miniconda on OS X and Linux with travis-ci
Run Tensorflow 2.x on Python 3.7
Handling of python on mac
Steps to install the latest version of OpenCV on OS X El Capitan without Homebrew
Update python on Mac to 3.7-> 3.8
Install pandas 0.14 on python3.4 [on Mac]
Notes on installing Python on Mac