help with pip installing opencv
-
hello,
i am trying to run this command in my m500 drone "pip3 install opencv-python" inside the provided ubuntu docker container from modal ai. i was able to simply do a pip3 install numpy and pip3 install pandas. but pip3 -v install opencv-python is becoming a very lengthy process taking almost 3 hours before failing with an error. i can understand from the debugger output that it is building the library somehow.
"ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly"
no matter what I try it won't install. is there an easy solution to get opencv working in the docker container ? i am working with is python 3.5.2 and pip 20.3.4
i consulted this stackoverflow question for solutions
thank you,
omair -
@Syed-Omair , I suggest that you try building opencv from source - the way we do it is shown here : https://gitlab.com/voxl-public/voxl-sdk/third-party/voxl-opencv/-/tree/add-python3-bindings/ -- this is a specific branch that enables python3 bindings.
I actually have pre-build deb for this here. This was built and tested for VOXL2, but it should work on VOXL1 in a 64-bit ubuntu docker image. Just before installing the deb, please create the following directory:
mkdir -p /usr/lib/python3.6/dist-packages/
this is the place where cv2.so will be copied for python to use. I fixed this on the branch but the deb was built some time ago and does not have this fix, so it will fail during install unless you create this folder.
You should remove (or just don't install) other opencv packages before you install this one.
Please try it out and let me know if it works for you. Also, if you want to build it yourself, you can see
build.sh
for build flags, etc. This is a somewhat stripped down version opencv. Building all of the components would indeed take hours on voxl.EDIT: the deb i provided may or may not work on VOXL1. The way it was built was actually on an ARM-based Mac inside a ubuntu arm docker, using native compiler flags. So i am not sure if it is compatible with armv8 or needs newer arch. However, you should give it a try. if the deb does not work for you, you can just try building this right on your VOXL1 inside docker using
build.sh native
option.Alex