Django giving [Errno 13] Permission denied
Question: I am developing an application with Python that parses a webpage and then
downloads the images contained on the webpage. I am using WAMP for the
webserver and DJango for the framework. The python script I have implemented
runs as expected (downloads images to my local desktop properly) on my local
computer, but when I try and run it using on the webserver with DJango and
WAMP, I get the error [Errno 13] Permission
denied:'C:\Users\user123\Desktop\images'. Below is my code, any ideas what's
causing the error.

    
    
    from django.http import HttpResponse
    from bs4 import BeautifulSoup as bsoup
    import urlparse
    from urllib2 import urlopen
    from urllib import urlretrieve
    import os
    import sys
    import zipfile
    from django.core.servers.basehttp import FileWrapper
    
    def getdata(request):
    out = r'C:\Users\user123\Desktop\images'
    if request.GET.get('q'):
        #url = str(request.GET['q'])
        url = "http://google.com"
        soup = bsoup(urlopen(url))
        parsedURL = list(urlparse.urlparse(url))
    
        for image in soup.findAll("img"):
            print "Old Image Path: %(src)s" % image
        #Get file name
        filename = image["src"].split("/")[-1]
        #Get full path name if url has to be parsed
        parsedURL[2] = image["src"]
        image["src"] = '%s\%s' % (out,filename)
        print 'New Path: %s' % image["src"]
        #       print image
        outpath = os.path.join(out, filename)
    
        #
        if image["src"].lower().startswith("http"):
            urlretrieve(image["src"], outpath)
        else:
            urlretrieve(urlparse.urlunparse(parsedURL), out) #Constructs URL from tuple (parsedURL)
    
        #Create HTML File and writes to it to check output (stored in same directory).
        html = soup.prettify("utf-8")
        with FileWrapper(open("output.html", "wb")) as file:
            file.write(html)
    
        #Create where zip file will be stored (same directory htmlparser file)
        zip = zipfile.ZipFile('C:\Users\user123\Desktop\Images.zip', 'w')
    
        #Path where file that will be zipped up is located
        path = 'images'
    
        #For each file, add it to the zip folder.
        for root, dirs, files in os.walk(path):
            for file in files:
                zip.write(os.path.join(root, file))
        zip.close()
    else:
            url = 'You submitted nothing!'
    
    return HttpResponse(url)
    


Answer: your user does not seem to have write permissions for the "images" directory.
set the directory to "world writeable" and try again.

