Short answer
I have found this work-around for the problem:
Install and configure pre-commit
in your base
conda environment instead of your project's conda environment.
Details
I just reproduced this error a year later, getting an identical error log.
This happened when I was trying to run git commit
with a Conda environment activated on Windows. While in that conda environment I was able to install packages, the mechanism by which pre-commit
installs its hooks ended up broken, with SSL unavailable and the same log shown in the question.
The fix for me was to deactivate my conda environment, install pre-commit
in my base
conda environment, and do one commit with base
activated. For some reason I still don't understand, SSL is available and works fine when pre-commit
installs its hooks from the base
conda env, but not from an activated project-specific environment.
Once the pre-commit
hooks are installed and configured, then I can activate my project's conda environment and do further commits from there, since pre-commit
reuses its cached installation of the hooks.
Full error log
Here's the error log on my machine, identical to what we can see on the screen shot in the question:
(my-conda-env) $ git commit
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\someone\\.cache\\pre-commit\\repot4mg0fom\\py_env-default\\Scripts\\python.EXE', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
Processing c:\users\someone\.cache\pre-commit\repot4mg0fom
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
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 with url: /simple/ruamel-yaml/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
stderr:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/ruamel-yaml/
WARNING: 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/ruamel-yaml/
WARNING: 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/ruamel-yaml/
WARNING: 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/ruamel-yaml/
WARNING: 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/ruamel-yaml/
ERROR: Could not find a version that satisfies the requirement ruamel.yaml>=0.15 (from pre-commit-hooks) (from versions: none)
ERROR: No matching distribution found for ruamel.yaml>=0.15
Check the log at C:\Users\someone\.cache\pre-commit\pre-commit.log
After running conda deactivate
:
(base) $ git commit
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check yaml...........................................(no files to check)Skipped
check json...........................................(no files to check)Skipped
fix end of files.....................................(no files to check)Skipped
[... rest of my checks]
I totally agree that this solution has bad smells: it's a work-around not a real fix. I agree that one should not install stuff in the base environment, and that all the project dependencies, including dev ones, should live in the project's venv. But... on Windows, this bug has affected both OP and myself.