-[] Install OpenCV
$sudo apt-get install python-numpy
$sudo apt-get install python-opencv
OpenCV should have entered with this, but since it did not work due to an error from here, deal with it
$python
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
If you look closely, you will notice that the path to cv2.so is not set [/usr/lib/python2.7/dist-packages/]
>>> import sys
>>> print sys.path
['', '/usr/local/pyenv/versions/2.7.13/lib/python27.zip', '/usr/local/pyenv/versions/2.7.13/lib/python2.7', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/plat-linux2', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/lib-tk', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/lib-old', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/lib-dynload', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/site-packages']
>>> exit()
$sudo updatedb
$locate cv2
/usr/lib/python2.7/dist-packages/cv2.so
/usr/src/linux-headers-4.4.0-75/arch/arc/include/asm/entry-arcv2.h
/usr/src/linux-headers-4.4.0-75/arch/arc/include/asm/irqflags-arcv2.h
$
So add PATH and re-execute
>>> import sys
>>> sys.path.append("/usr/lib/python2.7/dist-packages")
>>> print sys.path
['', '/usr/local/pyenv/versions/2.7.13/lib/python27.zip', '/usr/local/pyenv/versions/2.7.13/lib/python2.7', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/plat-linux2', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/lib-tk', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/lib-old', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/lib-dynload', '/usr/local/pyenv/versions/2.7.13/lib/python2.7/site-packages', '/usr/lib/python2.7/dist-packages']
>>> import cv2
libdc1394 error: Failed to initialize libdc1394
>>> exit()
Then another error occurs
When I checked the error content on Google, there was a comment from the person who dealt with it, so I will adopt it However, there is also "It is not a permanent solution.", So a different evacuation work may come out soon.
$ sudo ls /dev/raw1394
ls: cannot access /dev/raw1394: No such file or directory
$sudo ln /dev/null /dev/raw1394
$python
>>> import sys
>>> sys.path.append("/usr/lib/python2.7/dist-packages")
>>> import cv2
>>> cv2.__version__
'2.4.8'
Reference: OpenCV: libdc1394 error: Failed to initialize libdc1394
I added PATH with sys.path.append ("/usr/lib/python2.7/dist-packages")
, but it is troublesome to add PATH every time because only the set session is valid.
Create a definition file and change it so that PATH is set automatically
The location is likely to be related to the package in the PATH displayed in sys.path
Create a new custom.pth
in /usr/local/pyenv/versions/2.7.13/lib/python2.7/site-packages
custom.pth
/usr/lib/python2.7/dist-packages/
Recommended Posts