I wrote a script that involves outputting some information to a .txt file. A couple days ago this script worked just fine with no errors. Since then I have changed nothing in the script but now when I run it in Blender I get the following error:

traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
PermissionError: [Errno 13] Permission denied: 'input.txt'

With info from the various other Permission denied questions (here, here, here, and here) I have done some troubleshooting and gleaned the following information:

  • The file is not open anywhere else.
  • I can save the .blend file and open/import/export other files just fine, unlike the problems the above linked questions are addressing.
  • I have tried open('input.txt', 'w') from the command line within Blender and it throws the same error.
  • I have tried open('input.txt', 'r'), and open('input.txt', 'r+') as well, these throw [Errno 2] No such file or directory: 'input.txt', even though the file does in fact exist.
  • I can open and write to the exact same file from a python script outside of Blender just fine. So the problem seems to be from within Blender.
  • This exact same script worked just fine a couple days ago, it has not been modified since.

Any idea what could have changed and caused Blender (and Blender only) to no longer be able to access this file?

  • 1
    $\begingroup$ Were you possibly running Blender with administrator privileges before and not now? Did you reinstall or update Blender or somehow change the executable in the meantime? Are there any security software running, like firewalls or antivirus that could have been triggered by said change? Are there any non ASCII characters anywhere in the filepath? $\endgroup$ Dec 13, 2017 at 19:09
  • 1
    $\begingroup$ @DuarteFarrajotaRamos I don't know why it didn't occur to me to try running as administrator but I tried that and it worked. However now it baffles me as to why it worked initially as I definitely did not explicitly run as admin then. $\endgroup$
    – PGmath
    Dec 13, 2017 at 21:28
  • $\begingroup$ And why would windows require Blender to be elevated to run the code but not IDLE? $\endgroup$
    – PGmath
    Dec 13, 2017 at 21:31
  • 1
    $\begingroup$ Sounds like a file ownership issue; either the file itself, or the directory it's in. $\endgroup$ Dec 13, 2017 at 22:29

1 Answer 1


I had the same problem today! I don't know if It's too late now, but this is my solution: insert the entire file-path for your file.


file = open("C:\\Users\\userName\\Desktop\\Codes\\f.txt","w")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.