PermissionError: [Errno 13] Permission denied: '/path'
The OS refused the file operation — no permission, a directory passed to open(), or (on Windows) the file is open elsewhere.
Seen on:
Python
Meaning
On Linux the Python process user lacks rights. On Windows, Excel or another program locking the file also raises Errno 13. Opening a directory path with open() raises it too.
Common causes
- Process user lacks read/write permission
- Path is a directory, not a file
- File locked by another program (Windows)
- Writing into a system or site-packages directory without a venv
⚡ Quick fix
- Check ownership/permissions with ls -l
- Make sure the path points to a file
- Close the file in other programs
- Use a virtual environment instead of sudo pip
Detailed fix by platform
Linux
sudo chown -R $USER:$USER ./output
How to diagnose
- Path — File or directory?
- User — Which user runs Python?
- Lock — Open in another app?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026