0

I use conda Python environments. Whenever I try to run pre-commit install-hooks, I get the error

 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.

However, pip works just fine when I use it.

I already tried pre-commit clean, uninstalling pre-commit and reinstalling it (either with conda or pip), updating pip, switching off the VPN, and also any other solution I could find on Google. Nothing seems to work. Could you please help me?

The .pre-commit-config.yaml looks like this:

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)

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
karu
  • 465
  • 3
  • 12

2 Answers2

1

Anaconda environment is broken, not only on pre-commit, but every operation which uses SSL module.

Solution:

copying these files from Anaconda3/Library/bin to Anaconda3/DLLs :

libcrypto-1_1-x64.dll

libssl-1_1-x64.dll

Reference: SSL Error while installing any package from conda prompt

Kit Law
  • 323
  • 6
  • 15
0

The following helped me:

  • uninstall pre-commit (via pip/conda)
  • delete the pre-commit.exe (found by "where pre-commit"). That's crucial; otherwise it still uses this exe even though pre-commit is installed in the conda env, and I still got the same error
  • install pre-commit via conda; pip doesn't work because it still looks for the exe
karu
  • 465
  • 3
  • 12