FS#58849 - [python-pip] SSLError pip._vendor.requests.exceptions

Attached to Project: Arch Linux
Opened by Rugantio Costa (rugantio) - Sunday, 03 June 2018, 10:40 GMT
Last edited by Eli Schwartz (eschwartz) - Sunday, 03 June 2018, 18:17 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To No-one
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
Pip package seems broken, whatever I try to do I get this:
$ pip search lol
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
return ep.load()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
return self.resolve()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 20, in <module>
from pip._vendor.requests.exceptions import SSLError
ModuleNotFoundError: No module named 'pip._vendor.requests.exceptions'

Additional info:
* package version(s)
10.0.1-1

This task depends upon

Closed by  Eli Schwartz (eschwartz)
Sunday, 03 June 2018, 18:17 GMT
Reason for closing:  Not a bug
Additional comments about closing:  Caused by conflicting pip install from using pip install --upgrade pip. Don't run pip as root.
Comment by Eli Schwartz (eschwartz) - Sunday, 03 June 2018, 12:56 GMT
This works fine for me, python-requests is a dependency of python-pip. Do you somehow have a broken requests module?

from pip._vendor import html5lib, requests, six
is run only a couple lines before
from pip._vendor.requests.exceptions import SSLError

The first import clearly works fine, so it's correctly detecting requests, but then failing to get usable information from it???

What's the output of python -c 'import pip._vendor.requests; print(pip._vendor.requests.__file__)'
Comment by Felix (regenbogencode) - Sunday, 03 June 2018, 13:23 GMT
I'm experiencing the same issue. Running your command:
python -c 'import pip._vendor.requests; print(pip._vendor.requests.__file__)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'pip._vendor.requests' has no attribute '__file__'
Comment by Rugantio Costa (rugantio) - Sunday, 03 June 2018, 14:16 GMT
I get the same AttributeError, I'm using python-requests 2.18.4-1
Using grep I notice that the SSLError class is in a different dir (under urllib3), in fact I can import with:
from pip._vendor.requests.packages.urllib3.exceptions import SSLError

Maybe this can be the fix?
Comment by Eli Schwartz (eschwartz) - Sunday, 03 June 2018, 14:20 GMT
Then what exactly is "import pip._vendor.requests" importing...
If it didn't exist, it should return a ModuleNotFound error, so clearly it thinks something is there... but apparently not the python-requests module!

I should've asked to see the output of
python -c 'import pip._vendor.requests; print(pip._vendor.requests)'

(This will show what it thinks the module is, which very often *is* a __file__ attribute, but not always...)

What does this report?

ls /usr/lib/python3.6/site-packages/pip/_vendor
Comment by Bogdan Darius (BogdanDarius) - Sunday, 03 June 2018, 16:22 GMT
Hello I'm having similar issues.

The output of ls /usr/lib/python3.6/site-packages/pip/_vendor is:
certifi idna msgpack __pycache__ requests
chardet __init__.py pkg_resources.bak pytoml urllib3
Comment by Eli Schwartz (eschwartz) - Sunday, 03 June 2018, 16:43 GMT
That's entirely wrong, there should be nothing there except for __init__.py and __pycache__

... and my theory is confirmed. At least one person has a broken requests module that was never installed by pacman.

I guess you installed a version of pip outside of pacman, probably using pip install --upgrade pip, in order to get the updated version of pip before we finally released it into the repos.

You'll need to figure out how many untracked files you've got, which pacman does not know about, and remove them. A tool like https://aur.archlinux.org/packages/lostfiles will help you with this.
Comment by Felix (regenbogencode) - Sunday, 03 June 2018, 16:55 GMT
Thanks Eli! I fixed it by:

rm -r /usr/lib/python3.6/site-packages/pip
pacman -S python-pip --force

Comment by Rugantio Costa (rugantio) - Sunday, 03 June 2018, 17:04 GMT
Yes, the fix works for me as well, I guess you can close this bug. Thank you!
Comment by Eli Schwartz (eschwartz) - Sunday, 03 June 2018, 18:15 GMT
There's absolutely no reason to force it when there's no conflicting files... Just remove the files Pacman does not know about, using "lostfiles".

Loading...