无法在Pepper上的Choregraphe中导入python模块

时间:2017-06-08 13:48:21

标签: python nao-robot pepper choregraphe

我已经在official Google tutorial之后通过SSH在Pepper机器人上安装了Google语音API。

为了测试它,我创建了一个文件speechTest.py,我按如下方式导入API:

from google.cloud import speech

这很有效!到现在为止还挺好。但是当我想在Choregraphe的Python框中做同样的事情时,问题就出现了;当我收到错误时说:

[ERROR] behavior.box :createPythonModule:0
_Behavior__lastUploadedChoregrapheBehaviorbehavior_11325017632:/GoogleSTT_7:
User class evaluation failed with the error:
<class 'pkg_resources.DistributionNotFound'>
google-cloud-speech

我尝试了解决方案raised in the community但没有成功。当我在Choregraphe框中从Python打印sys.path时,我得到:

[WARN ] behavior.box :onLoad:15 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1811402208:/GoogleSTT_7: 
/usr/lib/python2.7/site-packages
/usr/lib
/home/nao/.local/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg
/usr/lib/python27.zip
/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
/home/nao/.local/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages/PIL
/usr/lib/python2.7/site-packages/gst-0.10
/usr/lib/python2.7/site-packages/gtk-2.0
/usr/share/dialog/
/home/nao/.local/share/PackageManager/apps/dialog_lexicon/./
/home/nao/.local/share/PackageManager/apps/dialog_adjust_volume/dlg_adjust_volume/
/home/nao/.local/share/PackageManager/apps/dialog_adjust_volume/my_apps_topic/
/home/nao/.local/share/PackageManager/apps/dialog_applauncher/dlg_applauncher/
/home/nao/.local/share/PackageManager/apps/dialog_applauncher/dlg_suggest_app/
/home/nao/.local/share/PackageManager/apps/dialog_battery_capacity/dlg_battery_capacity/
/home/nao/.local/share/PackageManager/apps/dialog_battery_level/dlg_battery_level/
/home/nao/.local/share/PackageManager/apps/dialog_bleep_sounds/dlg_bleep_sounds/
/home/nao/.local/share/PackageManager/apps/dialog_can_you_repeat/dlg_can_you_repeat/
/home/nao/.local/share/PackageManager/apps/dialog_clock/dlg_clock/
/home/nao/.local/share/PackageManager/apps/dialog_engines/dlg_engines/
/home/nao/.local/share/PackageManager/apps/dialog_goodbye/dlg_goodbye/
/home/nao/.local/share/PackageManager/apps/dialog_hello/dlg_hello/
/home/nao/.local/share/PackageManager/apps/dialog_help/dlg_help/
/home/nao/.local/share/PackageManager/apps/dialog_how_are_you/dlg_how_are_you/
/home/nao/.local/share/PackageManager/apps/dialog_impossible_moves/dlg_impossible_moves/
/home/nao/.local/share/PackageManager/apps/dialog_internet_connection/dlg_internet_connection/
/home/nao/.local/share/PackageManager/apps/dialog_lexicon/skin_B2B/
/home/nao/.local/share/PackageManager/apps/dialog_lexicon/skin_tmp_tweak/
/home/nao/.local/share/PackageManager/apps/dialog_manage_events/dlg_manage_events/
/home/nao/.local/share/PackageManager/apps/dialog_move_arms/dlg_move_arms/
/home/nao/.local/share/PackageManager/apps/dialog_move_hands/dlg_move_hands/
/home/nao/.local/share/PackageManager/apps/dialog_move_head/dlg_move_head/
/home/nao/.local/share/PackageManager/apps/dialog_posture/dlg_posture_pepper/
/home/nao/.local/share/PackageManager/apps/dialog_posture/dlg_posture_nao/
/home/nao/.local/share/PackageManager/apps/dialog_reflex_engaged/dlg_reflex_engaged/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_character/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_personal_info/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_humanoid/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_interaction/
/home/nao/.local/share/PackageManager/apps/dialog_robot_origins/dlg_robot_origins/
/home/nao/.local/share/PackageManager/apps/dialog_robot_relationships/dlg_robot_relationships/
/home/nao/.local/share/PackageManager/apps/dialog_robots/dlg_robots/
/home/nao/.local/share/PackageManager/apps/dialog_robots/dlg_asimov/
/home/nao/.local/share/PackageManager/apps/dialog_robots/dlg_famous_robots/
/home/nao/.local/share/PackageManager/apps/dialog_say_something_else/dlg_say_something_else/
/home/nao/.local/share/PackageManager/apps/dialog_set_offset/dlg_set_offset/
/home/nao/.local/share/PackageManager/apps/dialog_shutdown/dlg_shutdown/
/home/nao/.local/share/PackageManager/apps/dialog_stop_talking/dlg_stop_talking/
/home/nao/.local/share/PackageManager/apps/dialog_store/dlg_ade/
/home/nao/.local/share/PackageManager/apps/dialog_switch_language/dlg_switch_language/
/home/nao/.local/share/PackageManager/apps/dialog_thank_you/dlg_thank_you/
/home/nao/.local/share/PackageManager/apps/dialog_touch/dlg_touch_head/
/home/nao/.local/share/PackageManager/apps/dialog_what_can_you_do/dlg_what_can_you_do/
/home/nao/.local/share/PackageManager/apps//dialog_reflex/reflex/
/home/nao/.local/lib/python2.7/site-packages/google/cloud/

这表明应该找到Google套餐。我怎么解决这个问题?我不知道如何将Google Speech API导入Choregraphe项目。

编辑:当我在机器人的本地Python文件中输出sys.path时,我明白了:

/var/persistent/home/nao
/home/nao/.local/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg
/usr/lib/python27.zip
/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
/home/nao/.local/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages/PIL
/usr/lib/python2.7/site-packages/gst-0.10
/usr/lib/python2.7/site-packages/gtk-2.0

1 个答案:

答案 0 :(得分:2)

我相信在项目中使用未在机器人上默认安装的python库的最佳方法是将其添加到项目中。 这样,当您的软件包安装在机器人上时,您始终确保安装依赖项。它可能不是理想的,但更可靠的解决方案。

勘误: 实际上,如果你在项目(python文件)中的python中编写服务,你可以通过将它们放在python文件旁边来发送你的依赖项。 但是行为不能使用它们,你确实需要安装它们。

但你可以做的是在你的项目中使用google API编写一个python服务,并在你的behavior.xar中启动服务,使用它来做你需要的并在退出时停止服务。 (理想情况下,当行为停止时,您的服务可以自行停止)