To fix PermissionError: [Errno 13] Permission denied with Python open, we should make sure the path we call open
with is a file.
For instance, we write
import os
path = r"/path/to/file.txt"
assert os.path.isfile(path)
with open(path, "r") as f:
pass
to make sure that the path
is a path to a file with os.path.isfile
before we call open
to open the file at the path
.