I packed a python applications for Windows with PyInstaller
and InstallForge
and installed in the program directory. Besides the exe file there is also a config file in the application directory. When I run the the application from the exe created by PyInstaller
everything works fine. However, when I install the application with installation file created by InstallForge
, I get: PermissionError: [Errno 13] Permission denied
. When I run the application as administrator it works.
A simplified code to demonstrate the error looks like this:
def function():
with open('text.txt', 'w') as f:
f.write('readme')
if __name__ == '__main__':
function()
How do I get the permission to write to the folder in the program directory as a "normal" user ? Can the python code ask for permission?