pip seems to fall back on http if an extra URLs is configured

Created on 29 Oct 2017  Â·  25Comments  Â·  Source: pypa/pip

  • Pip version: Most recent
  • Python version: 3
  • Operating system: Raspbain

Description:

If I configure an extra repository for pip to download from I get a strange error:

# pip3 install jk_pwdinput
...
pip._vendor.requests.exceptions.HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/jk-pwdinput/

For some reason in this case pip tries to download from http://pypi.python.org/simple/jk-pwdinput/ which fails. It is completely unclear why pip attempts http instead of https if an extra url is configured.

What I've run:

pip3 install jk_pwdinput

But you can try with any other package. You will get the following error:

Collecting jk_pwdinput
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 795, in get_page
    resp.raise_for_status()
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
pip._vendor.requests.exceptions.HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/jk-pwdinput/

If I comment out extra-index-url in /etc/pip.conf everything works fine.

finder downstream auto-locked bug

All 25 comments

Hi @jkpubsrc!

What is your extra-index-url?

The URL is: http://foo:[email protected]:10004/

You can't access this server as it is a local server. I guess you can reproduce it with every http configuration. It was clearly reproducible yesterday on _two_ machines with a completely fresh system installation.

I have this same issue. If I provide an --extra-index-url or try to specify the index-url on the command line, that is if I try to change one of the index-url whether in pip.conf or on the command line, then pip falls back to using http://pypi.python.org/simple and fails with eg.

pip._vendor.requests.exceptions.HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/django-filter/

I have been at this for 2 days know, and I am sure there is a bug here somewhere, but I am unable to find it.

I have narrowed down this problem to python3.
Initially I ran into this problem trying to run: mkvirtualenv -p /usr/bin/python3.6 foo.

bahner@delphine:~/api/accounts/requirements$ python --version
Python 2.7.14
bahner@delphine:~/api/accounts/requirements$ python3 --version
Python 3.6.3

pip install -r requirments.txt will work, whereas
pip3 install -r requirments.txt will not.

pip3 install --upgrade pip -i https://pypi.python.org/simple
Collecting pip
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/lib/python3/dist-packages/pip/index.py", line 795, in get_page
    resp.raise_for_status()
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
pip._vendor.requests.exceptions.HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/pip/

@bahner I'm curious what the output of pip3 --version is... Could you tell me?

I'm getting the same error on Ubuntu 17.10 in a Python 2.7 virtualenv

$ pip --version
pip 9.0.1 from /home/nigel/src/project/local/lib/python2.7/site-packages (python 2.7)
$ python --version
Python 2.7.14
$ pip install -e . --extra-index-url=https://internal/pypi/simple
Obtaining file:///home/nigel/src/project
Collecting pytz (from project==0.1.dev0)
Exception:
Traceback (most recent call last):
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/home/nigel/src/project/local/lib/python2.7/site-packages/pip/index.py", line 795, in get_page
    resp.raise_for_status()
  File "/home/nigel/src/project/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/pytz/

@pradyunsg:
pip3 --version
pip 9.0.1 from /home/bahner/.local/lib/python3.6/site-packages (python 3.6)

I looked at issue 179 mentioned above and found that adding the correct fallback url solved my problem. Pip should probably try it's main index-url or fallback-url if ythe extra-index-url doesn't work.

Same issue here on both, python2.7.13 and python3.5.3, pip 9.0.1.
In my case it happens when I'm trying to install packages from my private repository that have dependencies in packages from official repository...

Setting index-url to https://pypi.pyth... in pip config file didn't help though. :(

I have a feeling that this might be due to Debian or Ubuntu unbundling of pip's own dependencies, which pip actually carries around with itself.

None the less, I don't think I really understand the issue here; I'll defer to other @pypa/pip-committers for this.

I agree, my feeling is that it's related to Debian's patching/unbundling. If anyone is able to reproduce on a non-Debian-derived distribution, that would go a long way towards confirming that there's an actual pip issue here.

The common thing in the provided tracebacks is around

File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893

There's no way pip itself would be running code directly out of an uninstalled wheel held in /usr/share/python-wheels, so I'm pretty convinced this is the fault of Debian patching.

@pfmoore So you also think this is a downstream issue, right?

Yes

Same problem here. It works with jessie but failed with stretch

Folks, is there any workaround for this error?

UPD: pip install --upgrade requests works for me

Not working on debian because it seems to use a self-contains requests package (I updated the local requests package as suggested by @vikt0rs before executing pip install) :

Exception:
Traceback (most recent call last):
  File "/srv/api/venv/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/srv/api/venv/lib/python3.5/site-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/srv/api/venv/lib/python3.5/site-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/srv/api/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/srv/api/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/srv/api/venv/lib/python3.5/site-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 795, in get_page
    resp.raise_for_status()
==>  File "/srv/api/venv/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
pip._vendor.requests.exceptions.HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/babel/

Maybe switching from the debian-provided-patched pip to an unpatched pip
would help?

Doing pip install --user --ignore-installed pip should be what is needed to
install an unpatched pip, assuming debian doesn't break other things like
sys.path ordering.

If someone could try to reproduce this using an unpatched pip, that would
be awesome!

If it's not reproduced, then we'll have a workaround for this issue and
someone should file a bug report over at debian's bug tracker.

On Fri, 17 Nov 2017, 13:54 Julien Meyer, notifications@github.com wrote:

Not working on debian because it seems to use a self-contains requests
package (I updated the local requests package as suggested by @vikt0rs
https://github.com/vikt0rs before executing pip install) :

Exception:
Traceback (most recent call last):
File "/srv/api/venv/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/srv/api/venv/lib/python3.5/site-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/srv/api/venv/lib/python3.5/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/srv/api/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/srv/api/venv/lib/python3.5/site-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/srv/api/venv/lib/python3.5/site-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/srv/api/venv/lib/python3.5/site-packages/pip/index.py", line 795, in get_page
resp.raise_for_status()
==> File "/srv/api/venv/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893, in raise_for_status
raise HTTPError(http_error_msg, response=self)
pip._vendor.requests.exceptions.HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/babel/

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pypa/pip/issues/4823#issuecomment-345176771, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADH7Sd3eVSOC9fr4V_AM49LgjYMtytgpks5s3ULLgaJpZM4QKfCq
.

I was of an impression that it is the client (pip) that you have to somehow set up to fallback to specific URL but it is actually the pypi server that you have to "fiddle" with.

So setting this argument: --fallback-url https://pypi.python.org/simple/ on pypiserver sorts out the issue.

@Jin-Xu Thank you :
The cause of my problem was the pypiserver configuration. I was using pypiserver version 1.2.0 and the default fallback url is http://...
I upgraded pypiserver to 1.2.1rc0 and it works now.

@pradyunsg Thanks. My virtual env didn't have site packages visible, so --user did not work. But I did the following:

$ pip install --ignore-installed --no-cache-dir pip
$ pip install --ignore-installed --no-cache-dir requests

and that solved the issue on my Kubuntu 17.04. I'm not sure if both statements are needed; I just wanted to get a working env again.

For completeness sake, this is the traceback I saw:

Collecting botocore==1.7.48 (from -r requirements_test.txt (line 16))                                                                                                                                   [450/2662]
Exception:                                                                                                                                                    
Traceback (most recent call last):                                                                                                                                                                                  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main                                                   
    status = self.run(options, args)                                                                                                                            
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/commands/install.py", line 353, in run                                               
    wb.build(autobuilding=True)                                                                                                                                                                           
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/wheel.py", line 749, in build                                                             
    self.requirement_set.prepare_files(self.finder)                                                                                                           
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files                                                                                             
    ignore_dependencies=self.ignore_dependencies))                                                                                                    
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/req/req_set.py", line 554, in _prepare_file                                                                                                 
    require_hashes                                                                                                                                        
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/req/req_install.py", line 278, in populate_link                                                
    self.link = finder.find_requirement(self, upgrade)                                                                                                      
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/index.py", line 465, in find_requirement                                                 
    all_candidates = self.find_all_candidates(req.name)                                                                                                 
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/index.py", line 423, in find_all_candidates                                                   
    for page in self._get_pages(url_locations, project_name):                                                                                                       
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/index.py", line 568, in _get_pages                                                                                                      
    page = self._get_page(location)                                                                                                                                                              
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/index.py", line 683, in _get_page                                                          
    return HTMLPage.get_page(link, session=self.session)                                                                                                                                                    
  File "/home/m/.virtualenvs/thermo/lib/python3.6/site-packages/pip/index.py", line 795, in get_page                                                                                  
    resp.raise_for_status()                                                                                                                                    
  File "/home/m/.virtualenvs/thermo/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/models.py", line 893, in raise_for_status                 
    raise HTTPError(http_error_msg, response=self)                                                                                                                                                            
pip._vendor.requests.exceptions.HTTPError: 403 Client Error: SSL is required for url: http://pypi.python.org/simple/botocore/                              

Note that was no mention of /usr/share/, but requests was picked from /.virtualenvs/thermo/share instead of lib as the other dependencies. I'm not sure what to make of it.

@maikhoepfel I get the following error

ajeya@node1:~/gr-inspector/build$ pip install --ignore-installed --no-cache-dir pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main
ajeya@node1:~/gr-inspector/build$

Any help is appreciated

Hi @ajeyaajeya, that seems unrelated to this issue. Please read all of the information in #5599, which will probably help with your problem.

pip install --ignore-installed --no-cache-dir pip did the trick, i.e. upgrade pip from version 9 to version 18

For users that are still facing this, the problem is the Debian/Ubuntu-provided pip command. One way to work around this problem is to run pip install --user --upgrade pip, and configuring your PATH so that $HOME/.local/bin is among the earlier entries.

There isn't anything actionable for pip maintainers here though, so I'm going to go ahead and close this issue.

Was this page helpful?
0 / 5 - 0 ratings