Search code examples
pythonurllibtext-mining

AttributeError: module 'urllib3' has no attribute 'urlretrieve'


I'm trying the code in this link for doing word2vec by keras.

I receive error on this line:

filename, _ = urllib.urlretrieve(url + filename, filename)

the error is:

AttributeError: module 'urllib' has no attribute 'urlretrieve'

for solving it I installed and imported urllib3 and change that line to:

filename, _ = urllib3.urlretrieve(url + filename, filename)

but I receive again with that error:

AttributeError: module 'urllib3' has no attribute 'urlretrieve'

How can I fix it?


Solution

  • Extending from comments section:

    As stated by documentation, you can access urlretrieve like this

    urllib.request.urlretrieve
    

    https://docs.python.org/3.4/library/urllib.request.html#urllib.request.urlretrieve