[英]installing python modules ImportError (dlib, imutils) raspberry pi
I am trying to install dlib on my raspberry py for a computer vision project with opencv. 我正在尝试在树莓派py上安装dlib,以使用opencv进行计算机视觉项目。 I installed successfully opencv, and I can import cv2 module in python.
我已经成功安装了opencv,并且可以在python中导入cv2模块。
$ python
>>> import cv2
>>> cv2.__version__
'3.3.0'
>>>
Then I installed 2 modules with pip install: dlib and imutils. 然后,我通过pip install安装了2个模块:dlib和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. 但是问题是在python中我无法导入它们,python找不到它们并且我无法使用它们。
>>> 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 编辑:@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)
I installed imutils with 我安装了imutils
sudo pip install imutils --target /usr/local/lib/python3.5/dist-packages/
into the python 3.5 folder and everything went right 进入python 3.5文件夹,一切正常
就像评论中所说的hoefling一样,您可能安装了多个python版本,因为Rpi随附2和3。如果您使用的是Python 3,请使用pip3而不是pip。
Your system has pip
symlinked to pip3
, so when you use pip
, it installs packages for python3
. 您的系统已将
pip
pip3
链接到pip3
,因此当您使用pip
,它将为python3
安装软件包。 Use the pip2
to target pip
for python2
: 使用
pip2
将python2
pip
作为目标:
$ pip2 install dlib imutils
It may be the case that you don't have pip
installed for python2
. 可能是您没有为
python2
安装pip
的情况。 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. 根据
sys.path
中的dist-packages
判断,您有一个debian或某些派生版本,因此很可能必须apt install python2-pip
才能将pip2
添加到系统中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.