默认python3版本,python2没有pip2模块,解决方案

问题:

树莓派 docker环境,默认python3版本,

OpenCV2.4只支持python2.7;

python2.7 没有face_recognition模块,需要pip2 install 安装导入;

python facerec_from_video_file.py 
Traceback (most recent call last):
  File "facerec_from_video_file.py", line 1, in <module>
    import face_recognition
ImportError: No module named face_recognition

python2.7 没有pip模块,需要安装pip2

/usr/bin/python2: No module named pip

直接通过pip安装出错,python3.6已经导入了

解决方案:

下载pip安装文件:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

用python2安装: 

python2 get-pip.py

get-pip.py如果还没有安装setuptools [2]wheel也安装 它们。setuptools是安装源代码分发所必需的 。首次安装才要,python3安装pip时已经安装了,所以不需要;

python2 get-pip.py --no-setuptools --no-wheel

安装face_recognition库:

pip2 install face_recognition

一直卡在这里

 Running setup.py bdist_wheel for face-recognition-models ... done

等待时间比较长,超过1小时;

参考链接:

linux 下切换Python版本(某用户,共存,替换)

https://www.cnblogs.com/rexyan/p/7485135.html

猜你喜欢

转载自blog.csdn.net/jacka654321/article/details/82379776
今日推荐