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

I am trying to write a program that will download mp3's off of a website then join them together but whenever I try to download the files I get this error:

Traceback (most recent call last):
File "/home/tesla/PycharmProjects/OldSpice/", line 214, in <module> main()
File "/home/tesla/PycharmProjects/OldSpice/", line 209, in main getMp3s()
File "/home/tesla/PycharmProjects/OldSpice/", line 134, in getMp3s
raw_mp3.add = urllib.urlretrieve("")
AttributeError: 'module' object has no attribute 'urlretrieve'

The line that is causing this problem is

raw_mp3.add = urllib.urlretrieve("")


As you're using Python 3, there is no urllib module anymore. It has been split into several modules.

This would be equivalent to urlretrieve:

import urllib.request
data = urllib.request.urlretrieve("http://...")

urlretrieve behaves exactly the same way as it did in Python 2.x, so it'll work just fine.


  • urlretrieve saves the file to a temporary file and returns a tuple (filename, headers)
  • urlopen returns a Request object whose read method returns a bytestring containing the file contents