How to correctly update requests in Ubuntu 14.04

I am currently using the python package, which depends on requests 2.7.0 or higher, but requests on my Ubuntu 14.04 system is version 2.2.1. I tried updating via pip:

pip install requests==2.7.0 

but it gives me an error saying:

 Not uninstalling requests at /usr/lib/python2.7/dist-packages, owned by OS 

I tried updating it using apt-get install --only-upgrade python-requests , but it says that it is already in the latest version (and it is not).

Then I tried installing in virtualenv, but it gives the same message as the pip message above.

Finally, I thought of two options:

1-) Unninstalling via apt-get and then installing via pip - I think this is too risky, as it will remove many other packages.

2-) Cloning from github and manual installation via setup.py, but I also fear that this might go wrong with other packages depending on it

What is the best way to do this? Is there something simple I'm missing?

+6
source share
2 answers

This works for me on Ubuntu 14.04:

 ~ โ€บ sudo apt-get install -u python-requests Reading package lists... Done Building dependency tree Reading state information... Done python-requests is already the newest version. python-requests set to manually installed. 0 to upgrade, 0 to newly install, 0 to remove and 15 not to upgrade. ~ โ€บ python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> requests.__version__ '2.0.1' >>> ~ โ€บ mkvirtualenv test New python executable in test/bin/python Installing setuptools, pip, wheel...done. ~ (test) โ€บ pip install requests Collecting requests Using cached requests-2.9.1-py2.py3-none-any.whl Installing collected packages: requests Successfully installed requests-2.9.1 ~ (test) โ€บ python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import requests >>> requests.__version__ '2.9.1' >>> 

I wonder why your version of OS / Ubuntu requests is 2.2.1 and mine is 2.0.1. Did you install the new version of the requests manually using any other mechanism than the official python-request package .deb? As @wilbur suggested in the comments above, is it possible that you ran sudo pip install requests at some point in the past? If so, it might be worth running sudo pip uninstall requests to see if you can get rid of it ...

+4
source

I needed requests> 2.10.0 for the built-in socks proxy support. Fix dpkg --remove --force-depends python-requests breaks apt (even if requests are set to peak).

apt-get install python-requests returns it in 2.2.1, the maximum version in a reliable repo. However, the yakkety ubuntu repo contains 2.10.0 python requests if necessary, so I did the following:

  apt-add-repository "deb http://us.archive.ubuntu.com/ubuntu/ yakkety main" apt-get update apt-get install python-requests # it installs 2.10.0 apt-add-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ yakkety main" apt-get update 

Attention! It is imperative to do a second apt-get update in order to remove the yakkety index so as not to run apt-get upgrade occasionally and disrupt your system.

So now I have the required version.

 $ sudo pip2 show requests --- Name: requests Version: 2.10.0 Location: /usr/lib/python2.7/dist-packages Requires: 
+3
source

All Articles