Skip to content
Advertisement

Cannot install openCV 3.1.0 with python3. CMAKE not including or linking python correctly

I’m trying to get OpenCV 3.1.0 installed with Python3 on my machine. Because I have Ubuntu 16.04, I am following this guide exactly:

http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/

However, I have trouble in step 4, after running cmake. The output of my cmake program has this snippet:

JavaScript

The cmake file doesnt seem to properly link the missing properties under the python section (libraries, numpy, packages_path). I tried compiling opencv and installing it, and when I load python3 and import cv, it says it could not find the cv package.

I tried modifying the CMAKE command, so instead of using what the guide suggested, I added three parameters to force cmake to include the missing python properties (the last three properties were my modification):

JavaScript

But still, the output of cmake is the same (it only lists the interpretter, and no other python properties), and when I try building opencv and installing it, my python interpretter could not find the opencv package.

My /usr/local/lib/python3.5/ file did NOT have a site-packages directory after I finished installing opencv either.

Can anyone point me in the right direction? I’ve been trying to search the past few hours on how to fix this, but could not find a way so far, so I’d greatly appreciate any guidance. Thank you!

Update

I realize that I have to add -D BUILD_opencv_python3=yes to the cmake command so that opencv looks for the python libraries. However, this is the new output that I get from cmake:

JavaScript

Any idea why cmake is not finding my python 3 libraries correctly (even when I add “-D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so ” to the cmake options)?

Update

I fixed the problem by deleting the entire /build directory, and running cmake on a fresh directory. I think the error continued to show up because of some caching done by cmake, but adding the flag -D BUILD_opencv_python3=yes seem to do the trick for me.

Advertisement

Answer

I fixed my problem by deleting the entire /build directory, and running cmake again (with -D BUILD_opencv_python3=yes). I think it gave an error because of some sort of caching from cmake, so when I deleted everything and started over again, the error was gone.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement