Skip to content Skip to sidebar Skip to footer

Python "ioerror: [errno 21] Is A Directory: '/home/thomasshera/pictures/star Wars'"

NOTE: the first part of 'code' isn't code, it's error message from terminal, SE made me format it that way. Linux machine using Python 2.7.6 I have download automator which is supp

Solution 1:

Second parameter of urlretrieve should be a path to a file not to a directory.

urllib.urlretrieve(url[, filename[, reporthook[, data]]])

Copy a network object denoted by a URL to a local file, if necessary.

You may fix it like:

urllib.urlretrieve(text_in_clipboard, "/home/thomasshera/Pictures/Star Wars/download.temp")

Solution 2:

Error occurs not in your code, but in the library you use - so why you see line 94 of file /usr/lib/python2.7/urllib.py. But the reason of it is in yours code. urllib.urlretrieve takes filename (not folder name) as its second argument. (In traceback we see that it is passed to function open which expects filename). This will work:

urllib.urlretrieve(text_in_clipboard, "/home/thomasshera/Pictures/Star Wars/data.txt")

Solution 3:

First off, the error you see has nothing to do with line 94 of your script, rather it's in urllib.py module.

Secondly, the problem is how you are using urlretrieve method. It takes in an URL and a filename. But you're using path to a directory, rather than a file. And urllib tells you exactly what I just said:

IOError: [Errno 21] Is a directory: '/home/thomasshera/Pictures/Star Wars'

Please, read urllib docs carefully.

Post a Comment for "Python "ioerror: [errno 21] Is A Directory: '/home/thomasshera/pictures/star Wars'""