0

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?

gazeranco
  • 55
  • 8

1 Answers1

1

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.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Yeah, thats the issue sorry for being such a noob. I now have a new issue in that its spawning IE instead of my default browser and searching for my new file instead of opening it but I will try and figure that out. - That issue is now fixed as well. – gazeranco Sep 19 '14 at 13:42