Procedure when you want to use a python module that is not installed as standard in Pepper
Install the module using pip. Install if pip is not included
$ brew install pip
pip install [module] --no-install --no-build is no longer available Use the -d option
Since it falls with tar, decompress it with a command
$ pip install [module] -d ./
From the Choregraphe project file Add directory for adding module with + mark Name it lib here.
Create a box for addition.
import sys
import os
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self)
self.path = ALFrameManager.getBehaviorPath(self.behaviorId) + "/lib"
if self.path not in sys.path:
sys.path.append(self.path)
def onUnload(self):
sys.path.remove(self.path)
def onInput_onStart(self):
pass
I've added a box called AddLib to the Github box library.
In python, the module in the directory append to sys.path Since it will be possible to import, the path of the lib directory added earlier is added. The AddLib box is made like a behavior under root.
Also, since the path is deleted when unloading It is recommended to place it as root.
When importing, if you write it outside the class of the box Because the load process that runs at startup tries to import before sys.path.append is called Make sure to describe import in the method of class.
Github https://github.com/hws-hitorobo/custom_box
Recommended Posts