Reputation: 55
I'm trying to download a file but when it's trying to write to the current directory it gives a permission error
Traceback (most recent call last):
File "C:\Users\HP User\Desktop\WWE Tool\MasterDownload.py", line 22, in <module>
with open(x, 'wb') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\HP User\\Desktop\\WWE Tool'
Code:
MasterDownload = requests.get(url=Master, headers=Heads)
fpath = os.getcwd()
with open(fpath, 'wb') as f:
f.write(MasterDownload.content)
I checked the current path and eveything looks fine, I just can't get around as to why it's not writing as I am an admin
Upvotes: 0
Views: 1280
Reputation: 619
You're actually trying to write to a directory (the process' current working directory - as obtained from os.getcwd()
), not to a file. Try selecting an actual file in that directory to write to instead of the directory itself, and the issue might go away.
Upvotes: 2