Pepper机械人:上传python模块 [英] Pepper robot: upload python modules
问题描述
我正在使用 Choregraphe 对辣椒机器人进行编程,并且我使用的是真正的机器人.我的问题是如何将python模块安装到机器人上?因为我需要使用 requests 包进行API调用.
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.
推荐答案
由于安全原因,root用户访问权限已停用,因此您将无法安装机器人上的软件包. 如果您希望使用外部库,则需要将它们打包为应用程序的一部分,如下所述(来自
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):
您将需要将软件包的路径添加到Python的sys.path.
You will need to add the path to your packages to Python's sys.path.
-
在Choregraphe Python框中执行以下操作:
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)
这将使应用程序"lib"目录中的所有Python文件均可导入.确保将这些文件导入Choregraphe软件包中,否则将不会安装它们.
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.
- 如果我们从项目根目录的Python模块中执行此操作,则需要使用:
python_path = os.path.join(os.path.abspath(__file__), 'lib')
将"current_path/lib"添加到sys.path
to get "current_path/lib" to be added to sys.path
这篇关于Pepper机械人:上传python模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!