Skip to content Skip to sidebar Skip to footer

Python Program Can't Open Txt File

I'm new to python and i'm trying to make a password manager. the problem is that my program works fine when i run it through IDLE or Pycharm but it stops running when i run it dire

Solution 1:

"it's just crashes when i run it from windows (rightclick ==> open with ==> python.exe)"

When you do this the working directory is C:\Windows\system32. Most likely you don't have write permissions to this directory. When running the script using the other methods the working directory is most likely the one containing the script. You need to change to a directory which you have write permissions for. Here is an example to use the current user's Documents folder:

import os dir = os.path.expanduser('~/Documents') os.chdir(dir)

Post a Comment for "Python Program Can't Open Txt File"