1

I'm doing a project that require cv2 and numpy in one of the scripts using choregraphe, but I get an error :

No module named cv2/numpy.

I think it is because choregraphe has its own python interpreter but I do not know how to install cv2 and numpy into the python of choregraphe.

How can I do it?

Javad Sameri
  • 1,218
  • 3
  • 17
  • 30
Jason.T
  • 11
  • 2

2 Answers2

2

It depends if you're using a real NAO or a simulated one.

  • Simulated one: choregraphe use its own embedded python interpreter, even if you add library to your system it won't change anything

  • Real NAO: the system python interpreter is used, you need to install those library to your robot (and not to the computer running choregraphe). As pip ofthen doesn't work fine in NAO, you'll have to manually copy library to /home/nao/.local/lib/python2.7/site-packages

Alexandre Mazel
  • 2,462
  • 20
  • 26
  • Hi Alexandre Mazel, I'm doing a simulated one. Is there any way to install numpy to the embedded python interpreter of choregraphe? – Jason.T Apr 12 '17 at 14:08
  • Mmmh. It's harder. Btw, if you want to do vision and don't have a real NAO, you can start tuning your algorithm in a standalone python script working on recording images for instance. Then once you'll have a NAO, you can upload your script to your NAO and start it from choregraphe as an external script (or cut and paste it from choregraphe)... – Alexandre Mazel Apr 13 '17 at 16:40
1

first do a pip install <lib or package> --target=<location in your local hard drive>

make a folder inside your choregraphe project named 'lib'

Copy the package inside that folder lib.

Create a box and put this on root.

do something like this

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)

the intent of this is to have your local folder lib be pointed to where python looks for libraries.

Now you can do the normal way of importing your python libraries

ianace
  • 1,646
  • 2
  • 17
  • 31
  • I did the above steps for numpy but I'm still getting the same error "No module named numpy". Does the def init(self) code need to be in the same box script where import numpy is? – Jason.T Apr 12 '17 at 11:28
  • do a log on self.path, then ssh on pepper or nao, see if that lib exists on that path – ianace Apr 12 '17 at 17:10
  • @Jason.T i see that you are using a simulated one, the answer i gave was when you have a nao/pepper robot – ianace Apr 19 '17 at 02:53