pythongitssldependency-managementpython-poetry

Poetry install failing with SSLError: Max retries exceeded on GitHub HTTPSConnectionPool


I am encountering an error when running the poetry install command in my Python project. The error message is as follows:

HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: ... (Caused by SSLError(FileNotFoundError(2, 'No such file or directory')))

I have tried the following troubleshooting steps, but none have resolved the issue:

  1. Verified my internet connection.
  2. Checked that I have the latest version of Poetry installed.
  3. Ensured my Git and OpenSSL installations are up-to-date.
  4. Confirmed that the repository URL is correct and accessible from a browser.

Despite all this, the error persists. It seems related to SSL or Git configuration, but I am unsure how to resolve it.

Environment Details:
OS: 14.7.1 (23H222)
Python version: 3.11.9]
Poetry version: 1.8.5
Git version: 2.45.2

Has anyone encountered this issue before or can provide guidance on how to resolve it?


Solution

  • Here’s how I resolved the issue:

    1. Install or Update certifi in the Virtual Environment

    Make sure the certifi package is installed and up-to-date:

    pip install --upgrade certifi
    

    Locate the cacert.pem File

    Use the following command to find where the cacert.pem file is located:

    python -m certifi
    

    2. Copy the cacert.pem File to the Expected Location

    From the error message (I tried to clone the repo from github using https), I saw that the virtual environment was looking for the cacert.pem file here: /Users/user/.../certifi/cacert.pem

    If the file is missing, copy it from another working virtual environment. For example:

    mkdir -p /Users/user/.../certifi/
    cp /path/to/working/venv/lib/python3.11/site-packages/certifi/cacert.pem /Users/user/.../cacert.pem
    

    3. Retry the Command

    After copying the cacert.pem file to the correct location, I retried the poetry install command and it worked!.