预提交安装挂钩不起作用(SSLError)

问题描述 投票:0回答:2

我使用 conda Python 环境。每当我尝试运行

pre-commit install-hooks
时,都会收到错误

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

...

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

但是,

pip
在我使用时效果很好。

我已经尝试过

pre-commit clean
、卸载
pre-commit
并重新安装(使用
conda
pip
)、更新
pip
、关闭 VPN,以及我在 Google 上可以找到的任何其他解决方案。似乎什么都不起作用。你能帮我吗?

.pre-commit-config.yaml
看起来像这样:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: check-yaml
    -   id: check-added-large-files
-   repo: https://github.com/psf/black
    rev: stable
    hooks:
    - id: black
      language_version: python3.8
-   repo: https://github.com/pycqa/isort
    rev: 5.10.1
    hooks:
      - id: isort
        name: isort (python)

python ssl pre-commit-hook pre-commit pre-commit.com
2个回答
1
投票

Anaconda 环境被破坏,不仅在预提交上,而且在每个使用 SSL 模块的操作上都被破坏。

解决方案:

将这些文件从 Anaconda3/Library/bin 复制到 Anaconda3/DLLs :

libcrypto-{版本}-x64.dll

libssl-{版本}-x64.dll

参考:从 conda 提示符安装任何软件包时出现 SSL 错误


0
投票

以下内容对我有帮助:

  • 卸载预提交(通过 pip/conda)
  • 删除pre-commit.exe(通过“where pre-commit”找到)。这很重要;否则,即使 conda 环境中安装了预提交,它仍然使用这个 exe,并且我仍然遇到相同的错误
  • 通过 conda 安装预提交; pip 不起作用,因为它仍在寻找 exe
© www.soinside.com 2019 - 2024. All rights reserved.