Reputation: 1465
I am trying to install OpenCV 3.0 for Python on Ubuntu 14.04 but after many installations (and StackOverflow pages read) it still does not work.
In Python (Python 2.7) when importing typing import cv2
I obtain this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libopencv_core.so.2.4: cannot open shared object file: No such file or directory
I have seen that this error may be due to the file /etc/ld.so.conf.d/opencv.conf
and therefore I wrote inside it the line /usr/local/opencv/
but it did not help (actually there is no folder opencv
in /usr/local/
on my computer...
For the installation I followed the instructions on this website: http://milq.github.io/install-opencv-ubuntu-debian/
I suspect errors occurred during the cmake
phase because I got failures like -- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
. I don't know what that means and if it is important for the installation...
I have other errors like
-- checking for module 'gstreamer-base-1.0'
-- package 'gstreamer-base-1.0' not found
During the make
phase I obtained this error
[ 31%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/qrc_window_QT.cpp.o
In file included from /home/xavier/OpenCV/build/modules/highgui/qrc_window_QT.cpp:9:0:
/home/xavier/OpenCV/build/modules/highgui/qrc_window_QT.cpp: In function ‘int qInitResources_window_QT()’:
/home/xavier/OpenCV/build/modules/highgui/qrc_window_QT.cpp:1749:25: warning: no previous declaration for ‘int qInitResources_window_QT()’ [-Wmissing-declarations]
int QT_MANGLE_NAMESPACE(qInitResources_window_QT)()
^
/usr/include/qt5/QtCore/qglobal.h:100:36: note: in definition of macro ‘QT_MANGLE_NAMESPACE’
# define QT_MANGLE_NAMESPACE(name) name
^
/home/xavier/OpenCV/build/modules/highgui/qrc_window_QT.cpp: In function ‘int qCleanupResources_window_QT()’:
/home/xavier/OpenCV/build/modules/highgui/qrc_window_QT.cpp:1758:25: warning: no previous declaration for ‘int qCleanupResources_window_QT()’ [-Wmissing-declarations]
int QT_MANGLE_NAMESPACE(qCleanupResources_window_QT)()
^
/usr/include/qt5/QtCore/qglobal.h:100:36: note: in definition of macro ‘QT_MANGLE_NAMESPACE’
# define QT_MANGLE_NAMESPACE(name) name
^
[ 31%] Generating opencl_kernels_superres.cpp, opencl_kernels_superres.hpp
Do you know what is wrong?
Upvotes: 2
Views: 5473
Reputation: 1465
I finally managed to solve my problems. Since this may interested other people, here how I proceed.
I removed entirely opencv from my computer:
sudo make unistall
in the repository where I wrote sudo make install
sudo find / -name "*opencv*" -exec rm -i {} \;
to remove all files containing "opencv"sudo find / -name "*cv2.so*" -exec rm -i {} \;
to remove all files containing "cv2.so"conda uninstall opencv
(if needed)I followed this link to install OpenCV2.4.10 for Python2.7: I did only the points 5,6,7 and 12 (the remaining ones are useless for what I wanted). I changed a bit the cmake
command and I typed
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D WITH_GTK=ON ..
Now if when typing import cv2
in Python you get an error like "No module named cv2", edit your .bashrc
file with the following command
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
You will have to reload the .bashrc file (source .bahsrc
) to apply the change.
To conclude, I don't know why it did not work previously but it appears that with this version of OpenCV I did not encounter any problem!
Good luck!
Upvotes: 1
Reputation: 162
You didn't install it correctly that's why you can't import it. Here is a guide on how to install it, (it is for an .older version but the commands are the same). OpenCV 3.0 Trouble with Installation
Upvotes: 0