Reputation: 55
When I run my script from Idle my program runs perfectly, but when I run the .py file and it spawns a shell @ C:\Python27\Python.exe my program fails with the following error:-
IOError: [Errno 13] Permission denied: 'my new file.html'
And the bit of code is:-
f = open("my new file.html", "w")
I have searched for this IOError but the things people are saying don't appear to tie in with what I am doing, which is writing out a file?
Upvotes: 0
Views: 253
Reputation: 386020
If it says "permission denied", that's telling you that you don't have permission to create that file. It isn't lying to you. The first rule of debugging is to always assume the error is telling you the literal truth.
Since you didn't supply a folder in the filename, it's trying to create a file in the current directory. You are probably in a protected folder. If you cd to a folder where you have write permissions, the problem will likely go away.
Upvotes: 1