HTTPError not being caught when module cannot be found

Bug #1579196 reported by Krystal
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-pip (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

I am running Ubuntu 16.04, with the python3-pip package installed, version 8.1.1-2.

We have a local PyPI server setup to serve python modules not available on the official PyPI server. I've added the local server using the extra-index-url option to my pip.conf file. Everything works as expected when I try to install one of the modules from the local PyPI server. However, when I try to install a module only available on the official PyPI server, say jsonschema, I get the following error:
Collecting jsonschema
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 328, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 748, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 512, in _prepare_file
    finder, self.upgrade, require_hashes)
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 273, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 440, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 398, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python3/dist-packages/pip/index.py", line 543, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 646, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 758, in get_page
    resp.raise_for_status()
  File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/models.py", line 840, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
pip._vendor.requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://172.17.0.1/packages/wheels-py3/simple/jsonschema/

The problem is that when the requests module raises HTTPError, it's being seen by pip as pip._vendor.requests.exceptions.HTTPError, while on pip/index.py line 775, it's trying to catch requests.HTTPError, so the raised error is not caught.

This error does not occur when pip is installed using the https://bootstrap.pypa.io/get-pip.py script since the requests module is bundled under _vendor, and the HTTPError is caught and handled accordingly.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-pip (Ubuntu):
status: New → Confirmed
Revision history for this message
Michael Liao (mliao) wrote :

I am experiencing the same issue, but with python-pip instead of python-pip3. Also on Ubuntu 16.04 and have python-pip 8.1.1-2 installed.

Revision history for this message
Alex Badics (alex.badics.bb) wrote :

Same with python-pip3 on Zesty (17.04). I believe this is the same issue as a github one: https://github.com/pypa/pip/issues/4580

Revision history for this message
Alex Badics (alex.badics.bb) wrote :

Sorry, I meant python3-pip.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.