Skip to content Skip to sidebar Skip to footer

Python Open Says File Doesn't Exist When It Does

I am trying to work out why my Python open call says a file doesn't exist when it does. If I enter the exact same file url in a browser the photo appears. The error message I get i

Solution 1:

If you are trying to open a file over internet you should do something like this (assuming that you are using python 3):

import urllib.requestfull_path_filename='https://' + settings.AWS_STORAGE_BUCKET_NAME + '.s3.amazonaws.com/' + file_namefile= urllib.request.urlopen(full_path_filename)

This will download the actual file. You can use file as an another file like object.

Post a Comment for "Python Open Says File Doesn't Exist When It Does"