При попытке установить какой-либо модуль для Python с помощью команды pip install
, если pip
не сможет проверить SSL-сертификат, вы увидите ошибку подобную следующей:
Could not fetch URL https://pypi.org/…/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=’pypi.org’, port=443): Max retries exceeded with url: /…/ (Caused by SSLError(SSLCertVerificationError(1, ‘[ SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: … — skipping
Если возникла проблема с проверкой SSL-сертификата репозитория, вы можете добавить его как --trusted-host
, что заставит pip
игнорировать проверку SSL-сертификата для этого репозитория.
Дельный Совет: Установка конкретной версии пакет в pip
! Читать далее →
Pip Install — Игнорирование SSL-сертификата
Внимание: Добавление репозиториев в доверенные источники отключает проверку SSL-сертификатов и открывает уязвимость для атаки man-in-the-middle.
Чтобы указать pip
на необходимость игнорирования проверки SSL-сертификата, добавьте необходимые репозитории в доверенные источники, например:
$ pip install --trusted-host pypi.org \ --trusted-host files.pythonhosted.org \ <package_name>
Доверенные хосты также могут быть прописаны в настройках:
# pip.ini (Windows) # pip.conf (Unix, macOS) [global] trusted-host = pypi.org files.pythonhosted.org
In my case, the root caused turned out to be an incorrect system date, which happened to be out of the certificate validity date range at the time of executing pip. This is related to the SSL library and not pip itself. Thus a simple wget or curl call to the offending URL will duplicate the issue.
Of course, I was also able to work around the issue quickly with —trusted-host
In general, this might be a common case with working with SBC like RasberryPi/BeagleBone or any other system where a real-time clock (RTC) is not present out of the box. So lesson learned: Use NTP for to keep system time up-to-date whenever possible.