1

I installed the nao Python SDK(naoqi) and when I run the script from the console it is correct, This is my code:

__author__ = 'raul'
from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech", "192.168.1.121", 9559)
tts.say("Hello World")

but when I run my script I have the following error with PyCharm:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7         /Users/raul/Documents/untitled/main.py

Traceback (most recent call last):
File "/Users/raul/Documents/untitled/main.py", line 3, in <module>
from naoqi import ALProxy
ImportError: No module named naoqi

How can I add the nao sdk to my project in Pycharm?

i export the nao sdk:

$ export PYTHONPATH=${PYTHONPATH}:/Users/Raul/Documents/naoSDK
$ export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/Users/Raul/Documents/naoSDK

Thanks!!

Image from Pycharm Image from Console

Joy Chopra
  • 120
  • 1
  • 2
  • 11
Lagul
  • 199
  • 1
  • 6
  • 19

4 Answers4

0

PyCharm simply invokes whatever Python interpreter you selected when you made the project.

When you create a new project, click the dropdown button to select the Python interpreter you want to use. In your case, select the Python interpreter to which you have installed the SDK.

Robert
  • 21
  • 1
0

PyCharm controls PYTHONPATH itself, it ignores whatever it gets from parent shell (I guess to keep a project's behaviour deterministic).

Check out the documentation for configuring the project's paths: https://www.jetbrains.com/pycharm/help/installing-uninstalling-and-reloading-interpreter-paths.html

You could also create a virtualenv for the SDK as illustrated in the answer to this question or in the documentation. You can re-use such virtualenv in other projects as well.

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
0

The doc explains how to use the Python SDK here: http://doc.aldebaran.com/2-5/dev/python/install_guide.html#mac, but it is not clear. In Python for Naoqi (dynamic module not initialized properly) they tried this:

DYLD_LIBRARY_PATH=<installation_directory>/lib DYLD_FRAMEWORK_PATH=<installation_directory> PYTHONPATH=<installation_directory>/lib/python2.7/site-packages python

It may work for you too.

Victor Paléologue
  • 2,025
  • 1
  • 17
  • 27
0

I just found out how to do it. I am writing here in case somebody else needs it. In your terminal open your .bashrc file $gedit .bashrc Then add the following paths to the file:

  1. export PYTHONPATH=${PYTHONPATH}:/your-path/pynaoqi-python/lib/python2.7/site-packages
  2. export DYLD_LIBRARY_PATH=/your-path/pynaoqi-python/lib
  3. export DYLD_FRAMEWORK_PATH=/your-path/pynaoqi-python

$source .bashrc

In your PyCharm, go to Run->Edit Congigurations->Environment Variables Click + on the corner add PYTHONPATH to the Name and /your-path/pynaoqi-python/lib/python2.7/site-packages to the Value. And similarly, other paths.

neak
  • 69
  • 4