I am trying to install dlib on my raspberry py for a computer vision project with opencv. I installed successfully opencv, and I can import cv2 module in python.
$ python
>>> import cv2
>>> cv2.__version__
'3.3.0'
>>>
Then I installed 2 modules with pip install: dlib and imutils. I can see them in pip freeze:
$ pip freeze | grep dlib
dlib==19.10.0
$ pip freeze | grep imutils
imutils==0.4.6
But the problem is that in python i can't import them, python does not find them and I can't use them.
>>> import dlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named dlib
>>> import imutils
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named imutils
How can I fix this problem?
Edit: @hoefling
$ python -c "import os, sys; print(os.linesep.join(sys.path))"
/usr/lib/python2.7
/usr/lib/python2.7/plat-arm-linux-gnueabihf
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/gtk-2.0
$ pip -V
pip 10.0.0 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
Your system has pip
symlinked to pip3
, so when you use pip
, it installs packages for python3
. Use the pip2
to target pip
for python2
:
$ pip2 install dlib imutils
It may be the case that you don't have pip
installed for python2
. In this case, you have to install it separately. Judging by dist-packages
in the sys.path
, you have a debian or some derivative, so most probably you'll have to apt install python2-pip
to add pip2
to the system.