首页 > 解决方案 > 我无法在 pycharm 中安装 opencv?

问题描述

我已经通过 cmd 使用pip install opencv-python. 但是当我在pycharm中运行简单的读写程序import cv2时,当我搜索时无法加载命令,我开始知道pycharm有其他方法来安装opencv。我这样做了,setting->project->project interperter然后我搜索了 opencv-python,但它在安装过程中给了我这个错误:

Collecting opencv-python
  Could not fetch URL https://pypi.org/simple/opencv-python/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/opencv-python/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv-python/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv-python/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv-python/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv-python/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv-python/
  Could not find a version that satisfies the requirement opencv-python (from versions: )
No matching distribution found for opencv-python
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

我有最新版本的 python 和 pip,但是虽然我收到了这个错误,但请任何人帮助我。

标签: opencvpycharmopencv-python

解决方案


您最初的错误是:

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))

如果您是 Windows 用户,请将以下路径设置为系统的PATH环境变量:

如果使用 Anaconda:

<system_path>\Anaconda3
<system_path>\Anaconda3\scripts
<system_path>\Anaconda3\Library\bin

如果您的系统上只安装了 Python,那么(我假设您的系统中安装了 Python 3.6):

<system_path_where_python_is_installed>\Python36
<system_path_where_python_is_installed>\Python36\Scripts
<system_path_where_python_is_installed>\Python36\Library\bin

然后尝试通过 PyCharm 安装 opencv。

希望这能解决您的问题。


推荐阅读