I was reading the documentation on the requests lib and it seems to be tremendously outdated or something.
I was going step by step, trying all the examples shown there and encountered a problem as I tried running the following piece:
import requests
from PIL import Image
from StringIO import StringIO
response = requests.get('http://www.github.com')
i = Image.open(StringIO(response.content))
That piece is from the official documentation. The first error that I got was the ImportError: no module named StringIO
Okay, then I found out that that module no longer exists, and in order to import StringIO one has to write from io import StringIO
. I did that. Tried running the code again and this time it errored out with TypeError:initial_value must be str or None, not bytes
.
What on earth did I do wrong? I don't follow...All I did was try running the code from the official doc....I'm clueless.
EDITED: And yeah...to use PIL one has to install Pillow.