无法使用pip3安装OpenCV

时间:2019-04-16 17:45:40

标签: python opencv ssl

当我尝试在Raspberry Pi上安装OpenCV进行对象检测时,出现此错误:

  

pip配置了需要TLS / SSL的位置,但是Python中的ssl模块不可用   open ssl版本-OpenSSL 1.1.0f 2017年5月25日(库:OpenSSL 1.1.0j 2018年11月20日)

我将Python 2.7用作全局软件包,并安装了OpenCV的所有软件包。

点子版本:pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

我使用pip3 install opencv-python安装OpenCV。

这是错误:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting opencv-python
  Could not fetch URL https://pypi.python.org/simple/opencv-python/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not fetch URL https://www.piwheels.org/simple/opencv-python/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement opencv-python (from versions: )
No matching distribution found for opencv-python

1 个答案:

答案 0 :(得分:1)

如果不自行构建,则无法在Raspberry Pi上安装OpenCV。这就是为什么您会收到错误No matching distribution found for opencv-python的原因。您必须自己在Raspberry Pi上构建它。最新版本还使用Python 3,您需要使用它,但应将其包含在Rasbian映像中。尝试python3 --version找出答案。

这里有详细的指南,您可以按照其构建和安装OpenCV:https://www.learnopencv.com/install-opencv-4-on-raspberry-pi/

上面的网站还提供了一个脚本,您可以下载该脚本并使用它来更轻松地进行安装。