Changes between Version 34 and Version 35 of en/ProgrammingRobotsCourse/GettingWwwInfo


Ignore:
Timestamp:
Mar 29, 2020, 6:20:08 PM (4 years ago)
Author:
Ales Horak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • en/ProgrammingRobotsCourse/GettingWwwInfo

    v34 v35  
    4242
    4343(Full example [raw-attachment:news.py:wiki:en/ProgrammingRobotsCourse/GettingWwwInfo news.py])
     44
     45In 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{{{
     47sudo pip2 install --target='/opt/Softbank Robotics/Choregraphe Suite 2.5/lib/python2.7/site-packages' \
     48    bs4
     49}}}
     50Use `pip` instead of `pip2` in older linux systems.
     51Beware that the version of just installed `bs4` package may be different from the version on the real robot.
     52
     53A 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
     55def __init__(self):
     56        GeneratedClass.__init__(self)
     57        self.folderName = os.path.join(self.behaviorAbsolutePath(), "../lib")
     58
     59def 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}}}
    4468
    4569== How to integrate info with robot?