I've been having problems for ages trying to get NAO libraries to play nicely in Python on my Mac (Snow Leopard).
First of all, I'd have to run Python 2.6 by doing:
>> python2.6
And then I'd try to import the naoqi library, and get the error:
Python 2.6.6 (r266:84292, May 17 2011, 11:58:30)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import naoqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/angelica/Nao/Library/naoqi-sdk-1.10.44-mac/lib/naoqi.py", line 35, in <module>
import inaoqi
File "/Users/angelica/Nao/Library/naoqi-sdk-1.10.44-mac/lib/inaoqi.py", line 7, in <module>
import _inaoqi
ImportError: dlopen(/Users/angelica/Nao/Library/naoqi-sdk-1.10.44-mac/lib/_inaoqi.so, 2): no suitable image found. Did find:
/Users/angelica/Nao/Library/naoqi-sdk-1.10.44-mac/lib/_inaoqi.so: mach-o, but wrong architecture
/Users/angelica/Nao/Library/naoqi-sdk-1.10.44-mac/lib/_inaoqi.so: mach-o, but wrong architecture
The main problem seemed to be making it all work with my MacPorts installation.
The PATH environment variable in my ~.profile had been modified by my MacPorts installation to look something like:
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:$PATH
I deleted this line from my .profile and opened a new terminal. Now the PATH was not being overridden by my .profile setting, so when I did
>> which python
I got
>> /usr/bin/python
More importantly, I can import my Nao library again! <3
h22:~ angelica$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import naoqi
>>>