AttributeError: 'Response' object has no attribute 'json'
14,808
Your version of the requests
library is too old. JSON support was added in version 0.12.1, released nearly 2 years ago.
The currently released version is 2.2.1.
Comments
-
AKIWEB almost 2 years
When I try to use the
.json()
method of a response object from the requests library, I get an error:>>> import requests >>> response = requests.get("http://example.com/myfile.json") >>> response_json = response.json() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'Response' object has no attribute 'json'
Why am I getting this error and how can I fix it?
-
AKIWEB about 10 yearsThanks. How would I update this in my Ubuntu machine? Any idea?
-
Martijn Pieters about 10 years@AKIWEB: I'm guessing you are using Ubuntu Precise? Use a
virtualenv
and install a new version into that? Alternatively, use a backport of a newer Ubuntu package. -
AKIWEB about 10 yearsI am not sure as this machine was provided to me by unix folks in our company.. Is there no way I can update this library directly in my ubuntu machine?
-
Martijn Pieters about 10 yearsIt's a Ubuntu package you have; a virtualenv will give you a private area to easily install library versions that you need to get your project working. The Ubuntu packages are way out of date, and I doubt you are going to get them updated.
-
Shekhar Samanta over 8 yearspip install requests --upgrade