[python] How do I read image data from a URL in Python?

For those of you who use Pillow, from version 2.8.0 you can:

from PIL import Image
import urllib2

im = Image.open(urllib2.urlopen(url))

or if you use requests:

from PIL import Image
import requests

im = Image.open(requests.get(url, stream=True).raw)

References: