requests 2.5.0 uninstall fails

Installing the latest (2.5.1) or 2.5.0 (in the examples, below), installs a version that can't be uninstalled or upgraded, though it imports without a problem. I show how 2.2.0 (my previous version) didn't have this problem.

Install 2.5.0:

```
dustin@deploy1:/usr/local/lib/python2.7/dist-packages$ sudo pip install requests==2.5.0
Downloading/unpacking requests==2.5.0
  Downloading requests-2.5.0-py2.py3-none-any.whl (464kB): 464kB downloaded
Installing collected packages: requests
Successfully installed requests
Cleaning up...
```

Can successfully import:

```
dustin@deploy1:/usr/local/lib/python2.7/dist-packages$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> 
```

Can't uninstall, though:

```
dustin@deploy1:/usr/local/lib/python2.7/dist-packages$ sudo pip uninstall requests
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 519, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2630, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2310, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2316, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
    from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
```

Cleanup, manually:

```
dustin@deploy1:/usr/local/lib/python2.7/dist-packages$ sudo rm -fr requests*
```

Installing 2.2.0 (the okay version):

```
dustin@deploy1:/usr/local/lib/python2.7/dist-packages$ sudo pip install requests==2.2.0
Downloading/unpacking requests==2.2.0
  Downloading requests-2.2.0-py2.py3-none-any.whl (623kB): 623kB downloaded
Installing collected packages: requests
Successfully installed requests
Cleaning up...
```

Uninstalls, fine:

```
dustin@deploy1:/usr/local/lib/python2.7/dist-packages$ sudo pip uninstall requests
Uninstalling requests:
  /usr/local/lib/python2.7/dist-packages/requests-2.2.0.dist-info/DESCRIPTION.rst
  /usr/local/lib/python2.7/dist-packages/requests-2.2.0.dist-info/METADATA
  /usr/local/lib/python2.7/dist-packages/requests-2.2.0.dist-info/RECORD
  /usr/local/lib/python2.7/dist-packages/requests-2.2.0.dist-info/WHEEL
  /usr/local/lib/python2.7/dist-packages/requests-2.2.0.dist-info/pydist.json
  /usr/local/lib/python2.7/dist-packages/requests-2.2.0.dist-info/top_level.txt
  /usr/local/lib/python2.7/dist-packages/requests/__init__.py
  /usr/local/lib/python2.7/dist-packages/requests/__init__.pyc
  /usr/local/lib/python2.7/dist-packages/requests/adapters.py
...
  /usr/local/lib/python2.7/dist-packages/requests/sessions.pyc
  /usr/local/lib/python2.7/dist-packages/requests/status_codes.py
  /usr/local/lib/python2.7/dist-packages/requests/status_codes.pyc
  /usr/local/lib/python2.7/dist-packages/requests/structures.py
  /usr/local/lib/python2.7/dist-packages/requests/structures.pyc
  /usr/local/lib/python2.7/dist-packages/requests/utils.py
  /usr/local/lib/python2.7/dist-packages/requests/utils.pyc
Proceed (y/n)? y
  Successfully uninstalled requests
```


This isn't our fault I don't think: your exception comes from pip. @dstufft?


## This looks like you installed pip using your system package manager and it needs a version of requests installed. 

Sent from my Android device with K-9 Mail. Please excuse my brevity.


Yea what @sigmavirus24 said. Some systems unbundle requests from pip.


@dstufft is this maybe related to debian preventing pip from removing packages installed by the system package manager?


No, I think it's just because Debian unbundles requests. So whatever version of requests you install to the system needs to be compatible with what pip expects.


Interesting that there's a difference in our compat module between 2.2.0 and 2.5.0.


Seems it was removed in https://github.com/kennethreitz/requests/commit/47d0517d66e8cf5832768262221f0357ae134ad1

I assume pip has already worked around this?


pip itself doesn't use it anymore, but the version of pip that Debian has in it's system packages is older than when we worked around it.


Yeah, so I'm pretty sure this is one of those cases where we shouldn't have let @jschneier remove that import in `requests.compat` (our fault) mixed with the constant of "`sudo pip install x` is evil; use virtualenvs".

We _could_ add the import back, but I would then mark it for deletion in 3.0 so this problem would just pop up again. So I'm going to close this since there's no solution that won't result in further breakage of other packages down the road.


Interesting. Thanks for considering the issue. So it's generally considered bad to install _PIP_ via the OS's package manager?


It's generally considered _best_ practice to do development inside of `virtualenv`s and in some cases, deploy inside of them as well so inter-application dependencies don't conflict with each other (unless you have a very sophisticated way of ensuring that two applications relying on the same dependencies don't break). Using the operating system's package manager for certain things (like `pip`) is okay _most_ of the time. It totally depends on what you're doing. With that said, this ticket isn't the place to discuss in depth downstream redistributors of python packages or what happens when they package python software.


I agree with the _virtualenv_ usage. I didn't realize that was decoupled
from the OS's version of _pip_ (how else would it even be available?).

Dustin

On Mon, Jan 26, 2015 at 9:20 AM, Ian Cordasco notifications@github.com
wrote:

> It's generally considered _best_ practice to do development inside of
> virtualenvs and in some cases, deploy inside of them as well so
> inter-application dependencies don't conflict with each other (unless you
> have a very sophisticated way of ensuring that two applications relying on
> the same dependencies don't break). Using the operating system's package
> manager for certain things (like pip) is okay _most_ of the time. It
> totally depends on what you're doing. With that said, this ticket isn't the
> place to discuss in depth downstream redistributors of python packages or
> what happens when they package python software.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/kennethreitz/requests/issues/2423#issuecomment-71466842
> .