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

dwbf0jvd  于 2023-02-19  发布在  其他
关注(0)|答案(1)|浏览(119)

我使用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并重新安装它(用condapip),更新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)
cngwdvgl

cngwdvgl1#

以下内容对我有帮助:

  • 卸载预提交(通过pip/conda)
  • 删除pre-commit.exe(通过“where pre-commit”找到),这是至关重要的;否则,即使在condaenv中安装了pre-commit,它仍然使用这个exe,并且我仍然得到相同的错误
  • 通过conda安装预提交;pip不工作,因为它仍然寻找exe

相关问题