'New to python, trying to give permissions to python to access a file keeps giving me "[Errno 13] Permission denied:'C:\\Users\\name\\Desktop\\folder'"
Tried following some online things and had a hard time following. Tried doing this:
import os, sys, stat
os.chmod('C:\\Users\\Name\\Desktop\\folder', stat.S_IREAD)
os.chmod('C:\\Users\\Name\\Desktop\\folder', stat.S_IROTH)
os.chmod('C:\\Users\\Name\\Desktop\\folder', stat.S_IWRITE)
os.chmod('C:\\Users\\Name\\Desktop\\folder', stat.S_IXUSR)
#os.chmod('C:\\Users\\Name\\Desktop\\folder', 0444)
file1 = open('C:\\Users\\Name\\Desktop\\folder', 'r')
Lines = file1.readlines()
I am attempting to open, read, and write a .txt file inside 'folder'. The issue is that python keeps saying that it needs permissions.
Stack trace when running current code:
[Errno 13] Permission denied: 'C:\\Users\\Name\\Desktop\\folder'
Stack trace:
> File "C:\Users\Name\source\repos\Invoice\Invoice\Invoice.py", line 10, in <module> (Current frame)
> file1 = open('C:\\Users\\Name\\Desktop\\folder', 'r')
Loaded '__main__'
Loaded 'runpy'
The program 'python.exe' has exited with code -1 (0xffffffff).
Stack trace when specifying the .txt inside the folder:
Message=[Errno 2] No such file or directory: 'C:\\Users\\User\\Desktop\\folder\\.txtFile'
Source=C:\Users\Name\source\repos\Invoice\Invoice\Invoice.py
StackTrace:
File "C:\Users\Name\source\repos\Invoice\Invoice\Invoice.py", line 10, in <module> (Current frame)
file1 = open('C:\\Users\\Name\\Desktop\\folder\\.txtFile', 'r')
I don't really have any idea what I'm doing,
thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
