سؤال

I'm trying to follow the documentation provided by Aldebaran here in order to get my NAO ready for Python programming. I correctly downloaded the NAOqi framework adapted to my OS (linux 64 bits) then I typed the command line $ export PYTHONPATH=${PYTHONPATH}:/path/to/python-sdk which, if I understand things right, should be typed in a terminal and not in a Python shell.

Then I typed import naoqi in a Python shell and got the ImportError: No module named naoqi error, so I tried troubleshooting and typed

import sys
print "\n".join(sys.path)

in the same Python shell and got the following output:

/home/*****
    /usr/bin
    /usr/lib/python2.7
    /usr/lib/python2.7/plat-linux2
    /usr/lib/python2.7/lib-tk
    /usr/lib/python2.7/lib-old
    /usr/lib/python2.7/lib-dynload
    /usr/local/lib/python2.7/dist-packages
    /usr/lib/python2.7/dist-packages
    /usr/lib/python2.7/dist-packages/PIL
    /usr/lib/python2.7/dist-packages/gst-0.10
    /usr/lib/python2.7/dist-packages/gtk-2.0
    /usr/lib/python2.7/dist-packages/ubuntu-sso-client
    /usr/lib/python2.7/dist-packages/ubuntuone-client
    /usr/lib/python2.7/dist-packages/ubuntuone-control-panel
    /usr/lib/python2.7/dist-packages/ubuntuone-couch
    /usr/lib/python2.7/dist-packages/ubuntuone-installer
    /usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol`

So I indeed don't have /path/to/python-sdk as I should, but not I'm blocked. What should I do to solve that?

(I am new to Linux, Python, and NAO, so perhaps the answer is obvious, but I've been trying to configure NAO for almost a week, so I definitely need some help.)

هل كانت مفيدة؟

المحلول

Suppose you have naoqi installed in /home/user/naoqi

1.- Open a text editor (Kate, Gedit,... whatever)

2.- Open the file /home/user/.profile

3.- At the end of the file, add the following line

export PYTHONPATH=${PYTHONPATH}:/home/user/naoqi

4.- Reboot (Close your session and login again also works, but just to be sure)

NOTE: Remember to change /home/user/naoqi with the correct path

نصائح أخرى

I had this issue for a while until I came across the Python SDK - Troubleshooting page which states that the path to the naoqi.py file that should be on your PYTHONPATH is /path/to/python-sdk/lib/python2.7/site-packages

I added the following line to my .bashrc file

export PYTHONPATH=${PYTHONPATH}:/path/to/naoqi/lib/python2.7/site-packages

and then ran source .bashrc in the terminal.

You can test if the path has been added correctly by running the following lines of code in a python2 terminal.

import sys
print "\n".join(sys.path)

You should see your above path in the list. Lastly try import naoqi in a python2 terminal to confirm.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top