You are not logged in.

#1 2018-05-27 04:18:24

imyxh
Member
Registered: 2018-05-27
Posts: 6

[SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

Hi, jumped from Ubuntu a few weeks ago, and I just stumbled across my first major problem.
Essentially, I can't get pip 10 to run at all. Here's what it gives me:

user@host ~ » pip
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'

And here's what I got from pydoc:

Help on package pip._vendor.requests in pip._vendor:

NAME
    pip._vendor.requests

PACKAGE CONTENTS
    __version__
    _internal_utils
    help
    packages

FILE
    (built-in)

(END)

... no wonder pip couldn't import requests.exceptions.... And since it's a vendored package, reinstalling python-requests doesn't do anything. I can't reproduce the problem with a clean virtualenv, so I suspect my pip._vendor.requests might just be broken. But I really don't know, so are there any ideas on how I could fix this?

Last edited by imyxh (2018-05-27 18:51:16)

Offline

#2 2018-05-27 04:38:51

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2018-05-27 05:49:35

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

Well, this is the pip from testing, yes.

But I don't get this error message at all, and I'm extremely confused where it comes from, since the pip in testing correctly depends on requests (hence why it works for me).

The bugreport you linked, jasonwryan, discusses how we switched this, which presumably does have something to do with the issue, but unfortunately not in a way which provides obvious clues what the issue is.

It also links to https://bugs.archlinux.org/task/58670 which details the completely different issue of incompatible pip._vendor.packaging vs pip._vendor.pkg_resources.extern.packaging which is slightly different. So pip is definitely broken, just not like this???


(We discussed this a bit on IRC.)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2018-05-27 18:49:13

imyxh
Member
Registered: 2018-05-27
Posts: 6

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

I discovered something interesting today.
If I just `cd /usr/lib/python3.6/site-packages/pip/_vendor/ && sudo mv requests requests.bak`, I can successfully import pip._vendor.requests.exceptions in the Python console.
After doing so, pip throws a new error, ending with:

  File "/usr/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 22, in <module>
    from pip._vendor.pkg_resources import RequirementParseError, parse_requirements
ImportError: cannot import name 'RequirementParseError'

I then tried the same trick with `sudo mv pkg_resources pkg_resources.bak`, and pip now works fine. I have no idea why it works, but I guess that's the whole spirit of Python.

Eschwartz wrote:

the pip in testing correctly depends on requests (hence why it works for me)

Well, my version of python-pip also depends on requests. I probably goofed something up on the install.

I suppose this thread is solved, for now at least.

Offline

#5 2018-05-27 23:03:42

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

I felt sure somehow that we'd discussed this and you'd confirmed that you didn't install anything with sudo pip. Because pacman did not install those files; they're not owned by testing/python-pip, and for good reason.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#6 2018-05-28 02:15:10

imyxh
Member
Registered: 2018-05-27
Posts: 6

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

Well, I know that I didn't install either of those via pip. Perhaps another pip package I installed had a vendored dependency—if that's a thing.

Last edited by imyxh (2018-05-28 02:18:52)

Offline

#7 2018-06-05 14:49:03

trevdev
Member
Registered: 2018-03-13
Posts: 6

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

imyxh wrote:

I discovered something interesting today.
If I just `cd /usr/lib/python3.6/site-packages/pip/_vendor/ && sudo mv requests requests.bak`, I can successfully import pip._vendor.requests.exceptions in the Python console.
After doing so, pip throws a new error, ending with:

  File "/usr/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 22, in <module>
    from pip._vendor.pkg_resources import RequirementParseError, parse_requirements
ImportError: cannot import name 'RequirementParseError'

I then tried the same trick with `sudo mv pkg_resources pkg_resources.bak`, and pip now works fine. I have no idea why it works, but I guess that's the whole spirit of Python.

Eschwartz wrote:

the pip in testing correctly depends on requests (hence why it works for me)

Well, my version of python-pip also depends on requests. I probably goofed something up on the install.

I suppose this thread is solved, for now at least.

I had the exact same issue as the original post on one Arch machine but not another with the pip 10.0.1 upgrade. I don't ever recall miss-using pip on either machine. Either way your above quoted work-around solved my issue as well (for now). Pip now runs, but I've yet to try to install or upgrade any packages with it yet. I hope it works!

Useless side note: Upgrading your package manager shouldn't cause nebulous errors. If anyone can explain why this happened, that would be awesome. I'm fully aware that I'm not offering any useful clues because frankly I don't even know where to start.

Offline

#8 2018-06-05 15:18:25

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

https://bugs.archlinux.org/task/58849

It's been thoroughly confirmed that a number of people who all had pip break the exact same way, all had untracked files (not part of the pip package) installed in pip's module directory.

This is bad, because it means *someone* (maybe you did but forgot, maybe you did it in your sleep, maybe your roommate/neighbor did it to be "funny", assuming they even know how to use Arch Linux) ran "sudo pip install --upgrade pip" in order to get a newer version of pip than the one pacman knew about. The result is that pip broke, because you had the conflicting bits and pieces of two installs floating around in the same folder trying to use each others' incompatible files.

Lesson learned: do not use sudo pip, ever. Use "pip install --user" or proper virtualenv setups.

You can even force --user to be default:

$ cat ~/.config/pip/pip.conf 
[install]
user = yes
no-binary = :all:

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#9 2018-06-06 19:38:41

soupault
Member
Registered: 2014-06-07
Posts: 2

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

For what it's worth, running the following solved the issue for me:

sudo rm -rf /usr/lib/python3.6/site-packages/pip /usr/lib/python3.6/site-packages/pkg_resources
sudo pacman -S python-setuptools python-pip

Offline

#10 2018-07-04 18:46:13

morgulbrut
Member
Registered: 2012-01-06
Posts: 3

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

soupault wrote:

For what it's worth, running the following solved the issue for me:

sudo rm -rf /usr/lib/python3.6/site-packages/pip /usr/lib/python3.6/site-packages/pkg_resources
sudo pacman -S python-setuptools python-pip

Not every hero wears a cape...

Offline

#11 2018-07-16 13:16:29

AmirIHz
Member
From: The Netherlands
Registered: 2016-10-23
Posts: 1

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

soupault wrote:

For what it's worth, running the following solved the issue for me:

sudo rm -rf /usr/lib/python3.6/site-packages/pip /usr/lib/python3.6/site-packages/pkg_resources
sudo pacman -S python-setuptools python-pip

Thank you very much. That solved the issue for me too. :-)

Offline

#12 2019-03-18 11:21:08

wis
Member
Registered: 2019-02-15
Posts: 14

Re: [SOLVED] pip: No module named 'pip._vendor.requests.exceptions'

soupault wrote:

For what it's worth, running the following solved the issue for me:

sudo rm -rf /usr/lib/python3.6/site-packages/pip /usr/lib/python3.6/site-packages/pkg_resources
sudo pacman -S python-setuptools python-pip

that didn't work for me, I have the a similar issue, with a similar error message caused by a different package  -"python-progress", and I have python 3.7 installed not 3.6.

what worked for me is installing the latest patched python-pip package, as advised here: https://bbs.archlinux.org/viewtopic.php … 5#p1835455

by updating my system, with this command:

sudo pacman -Syu

Last edited by wis (2019-03-19 14:56:21)

Offline

Board footer

Powered by FluxBB