| 44 | |
| 45 | In virtual robot, if you get a runtime error: ''No module named bs4'', you may need to install the package into the Choregraphe environtment via: |
| 46 | {{{ |
| 47 | sudo pip2 install --target='/opt/Softbank Robotics/Choregraphe Suite 2.5/lib/python2.7/site-packages' \ |
| 48 | bs4 |
| 49 | }}} |
| 50 | Use `pip` instead of `pip2` in older linux systems. |
| 51 | Beware that the version of just installed `bs4` package may be different from the version on the real robot. |
| 52 | |
| 53 | A safe option to include new packages is to install the package (e.g. `yourmodule`) in the application directory (e.g. `lib`) and import it like: |
| 54 | {{{#!python |
| 55 | def __init__(self): |
| 56 | GeneratedClass.__init__(self) |
| 57 | self.folderName = os.path.join(self.behaviorAbsolutePath(), "../lib") |
| 58 | |
| 59 | def onInput_onStart(self): |
| 60 | if self.folderName not in sys.path: |
| 61 | sys.path.append(self.folderName) |
| 62 | import yourmodule |
| 63 | # ... use yourmodule |
| 64 | if self.folderName in sys.path: |
| 65 | sys.path.remove(self.folderName) |
| 66 | self.onStopped() #activate the output of the box |
| 67 | }}} |