Can not get opencv imported in either python or node.js

Both import opencv from "opencv" in node.js, as well as import cv2 in python fail (example attachment)

Any ideas on how to fix?

1 Like

Hi @rohaninejadm

First off, welcome to the Pipedream community. Happy to have you!

Just reading through the OpenCV package on pip, it sounds like you may need to install the headless version of the package:

b. Packages for server (headless) environments (such as Docker, cloud environments etc.), no GUI library dependencies

These packages are smaller than the two other packages above because they do not contain any GUI functionality (not compiled with Qt / other GUI components). This means that the packages avoid a heavy dependency chain to X11 libraries and you will have for example smaller Docker images as a result. You should always use these packages if you do not use cv2.imshow et al. or you are using some other package (such as PyQt) than OpenCV to create your GUI.

  • Option 3 - Headless main modules package: pip install opencv-python-headless
  • Option 4 - Headless full package (contains both main modules and contrib/extra modules): pip install opencv-contrib-python-headless (check contrib/extra modules listing from OpenCV documentation)

There may be additional limits on the Node.js version of the package as well.

thanks for the speedy response!! This might be a noob question, but how do I tell pipedream how to install a pip dependency (instead of having it doing itself behind the scenes?)

just so its clear, no matter which pip package i install, the way you import it is import cv2; thus we have a many to one problem and PipeDream couldn’t know which pip package I want it to install?

I’m running into this issue too. Help would be greatly appreciated!

Hi @rockyduan , first off, welcome to the Pipedream community. Happy to have you!

I’m sorry but at this time the OpenCV package is only importable by one name, even if you want the headless option.

The team is aware of this limitation, but unfortunately for now it appears that we cannot support OpenCV in workflows with their current import style.