Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly update requests in Ubuntu 14.04

I am currently using a python package that depends on requests 2.7.0 or greater, but the requests in my system, Ubuntu 14.04, is version 2.2.1. I tried to upgrade 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 to upgrade it by using apt-get install --only-upgrade python-requests, but it says that it is already on the latest version (and it's not).

Then I tried to install in a virtual env, but it gives the same message as the pip message above.

Finally, I thought about two options:

1-) Uninstalling via apt-get and then installing via pip - I think it's too risky, since it will uninstall a lot of other packages.

2-) Cloning from github and manually installing via setup.py, but I also fear that it may mess with other packages depending on it

What is the best way to do it? Is there something simple I am missing?

like image 953
Tales Pádua Avatar asked Mar 03 '16 16:03

Tales Pádua


1 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 OS/Ubuntu version of requests is 2.2.1, whereas mine is 2.0.1. Have you installed a newer version of requests manually, via some other mechanism than the official python-requests .deb package? As suggested by @wilbur in the comments above, is it possible you have run 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...

like image 84
Tom Dalton Avatar answered Sep 28 '22 02:09

Tom Dalton