adri567
adri567

Reputation: 661

cannot write to file if I run .exe

I am writing a short program where I want to write an array full of street names to a .txt file. Everyting works fine, but if I convert the python code to a .exe with pyinstaller, I cant write to a new .txt file anymore. Why does this happen?

    with open(f"C:\\Users\\auser\\Desktop\\tset\\{txtname}.txt", "a") as txt_file:
        for line in new_addresses:
            txt_file.write(line + "\n")

    txt_file.close()

this is how I create the .exe:

pyinstaller --onefile streets.py

Traceback (most recent call last): File "streets.py", line 65, in PermissionError: [Errno 13] Permission denied: 'C:\Users\auser\Desktop\tset\test.txt' [7048] Failed to execute script rewriteword

Upvotes: 0

Views: 703

Answers (1)

adri567
adri567

Reputation: 661

I got this to work now. My anti virus program was blocking for some reason the execution.

Upvotes: 0

Related Questions