Pepper robot: upload python modules

泄露秘密 提交于 2019-12-01 05:31:07

问题


I'm programming a Pepper robot with Choregraphe and I'm using a real robot. The problem I have is how can I install python modules to the robot? because I need to use the requests package to make API calls.

I have been browsing in the internet but I don't found any solution.


回答1:


Root access is deactivated for security reasons so you won't be able to install a package on the robot. If you wish to use external libraries you need to package them as part of your app, as explained below (from https://community.ald.softbankrobotics.com/en/forum/import-libs-py-choregraphe-3578):

You will need to add the path to your packages to Python's sys.path.

  1. Do to that from your Choregraphe Python box do something like this:

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

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

  1. If we do this from a Python module that is at the root of the project, you will need to use:

python_path = os.path.join(os.path.abspath(__file__), 'lib')

to get "current_path/lib" to be added to sys.path



来源:https://stackoverflow.com/questions/45799150/pepper-robot-upload-python-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!