Solved
I had the same issue; the problem was not in my user profile. My script would run fine sometimes and other times it would error out with the same error message in this topic. What I found out is that when it failed, I had an Edge window open (to this site), which happens to be also creating and locking some files in the same TMP directory, if I close my Edge browser window, the locked files created in the TMP folder by that window are deleted, and when I run the script, it works just fine. I also tried deleting the TMP folder and making sure I close all browser windows and then run the script, it works, it even recreates the TMP folder.