Import libs py on choregraphe ?

Is it possible to import a python library in a box's choregraphe , and if "yes" how? thank you


Helo Siddharta, our engineers are aware of your question and should get back to you soon. Wink

Kind regards,


  • Hi, i need some serious help, i have written a game code in python and i want nao to play it, how can i use my code in choregraphe?

  • Hi, i need some serious help, i have written a game code in python and i want nao to play it, how can i use my code in choregraphe?

Hello Siddharta,

There are different ways to use a Python library with Choregraphe boxes.

  1. The best way: you can upload your library in the project content of your Choregraphe behavior. In Choregraphe, go to the Project Content widget, click +, import files, and select your library. You can also import a whole folder. Then create a Python box, and inside you can write: import sys [...] try: import MyGreatLib except: sys.path.append(ALFrameManager.getBehaviorPath(self.behaviorId)) import MyGreatLib

  2. If your library is not to heavy, and you just need to use it once or twice, you can copy paste it in a Choregraphe box, then create a global or shared variable referencing the main object of your library, in order to use it in other boxes for instance. This is, however, a very "sketchy" method that won't get you far, in my opinion

Does it help? Best,


  • And don't forget to do a reload(MyGreatLib) after the first import to make sure you refresh it (if you've updated it in the meantime).

  • merci

  • Hello Céline B:

    I tried the method 1,but it returns an error.I don't know why,can you help me? Error prompt is as follows:

    [ERROR] :_safeCallOfUserMethod:281 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1945112512__root__hello_1: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/", line 271, in _safeCallOfUserMethod func() File "", line 27, in onInput_onStart ImportError: No module named hello


it's quite simple: use import, eg:

import yourlib

... yourlib.yourmethod ...

BUT: 1. yourlib must be in the /home/nao/.local/lib/python2.7/site-packages/ 2. this folder has to be created before naoqi launch 3. or yourlib could be located in your project, and so you'll need to use the sys.path.append tricks... as refered in:

Good luck,


1 comment
  • You can also include the packages in your application itself. That way they are installed normally along with your other files by Choreograph. To do that you will need to add the path to your pacakges to Python's sys.path. Do to that from your Choreograph Python box do something like this:

    import os, sys
    python_path = return os.path.join(self.behaviorAbsolutePath(), 'lib')
    if python_path not in sys.path:

    This will make any Python files in the "lib" directory in your application importable. Make sure to import those files in your Choreograph package, otherwise they won't be installed.

Whaoo Thks Emilie, Celine, Amazel and Philippe Wink merci.

1 comment
Back to top