Loanb222 Loanb222 - 1 year ago 225
Python Question

How can I use urllib.request.urlretrieve with python 2.7

I am trying to get images dowloaded from so that I can create a haar cascade classifier. I am following this tutorial but I am using python 2.7 instead of python 3. So in the tutorial he has the line:

urllib.request.urlretrieve(img, pathToImage)

Instead of
import urllib.request
I did this
import urllib2
So I tried this but it isn't vaild

urllib2.urlretrieve(i, "Negatives/"+str(num)+".jpg")

Thank you in Advance!

Answer Source

You just need to import urllib without '2'

import urllib
urllib.urlretrieve(i, "Negatives/"+str(num)+".jpg")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download