Skip to content

Commit

Permalink
Add block to catch connection and proxy errors
Browse files Browse the repository at this point in the history
This allows us to output a more specific error message to help users in
common cases.
  • Loading branch information
uranusjr committed Aug 9, 2020
1 parent bc37c60 commit f3a04ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/html/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,10 @@ archives are built with identical packages.
to use such a package, see :ref:`Controlling
setup_requires<controlling-setup-requires>`.

.. _`Using pip from your program`:
Fixing network errors
=====================

TODO

Fixing conflicting dependencies
===============================
Expand Down
12 changes: 11 additions & 1 deletion src/pip/_internal/index/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from pip._vendor import html5lib, requests
from pip._vendor.distlib.compat import unescape
from pip._vendor.requests.exceptions import RetryError, SSLError
from pip._vendor.requests.exceptions import ProxyError, RetryError, SSLError
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request

Expand Down Expand Up @@ -460,6 +460,16 @@ def _get_html_page(link, session=None):
except SSLError as exc:
reason = "There was a problem confirming the ssl certificate"
logger.warning("Could not fetch URL %s: %s: %s", link, reason, exc)
except (requests.ConnectTimeout, ProxyError):
template = (
"Skipping URL %s since the connection timed out. This is likely "
"caused by a misconfigured network or proxy."
)
logger.warning(template, link)
logger.warning(
"For help, visit "
"https://pip.pypa.io/en/latest/user_guide/#fixing-network-errors"
)
except requests.ConnectionError as exc:
reason = "connection error"
logger.warning("Could not fetch URL %s: %s: %s", link, reason, exc)
Expand Down

0 comments on commit f3a04ac

Please sign in to comment.