Pyinstaller app is accessing txt files, but not writing to them (works before app compilation)

后端 未结 1 1825
渐次进展
渐次进展 2020-12-04 00:41

settings.txt is stored and accessed within the compiled single file app, but it\'s not being written to. This works prior to Pyinstaller compilation when the file is in the

相关标签:
1条回答
  • 2020-12-04 01:45

    If you are on Windows, _MEIPASS returns the "short" name for the path in case that any component of it is more than 8 characters long. So, to test that this is the issue, try to make it a one-folder frozen app and then move it in a simple and short path: e.g., C:/test.

    If this is the issue, you can workaround the problem by retrieving the long path using something like:

    if hasattr(sys, '_MEIPASS'):
        import win32api
        sys_meipass = win32api.GetLongPathName(sys._MEIPASS)
    
    0 讨论(0)
提交回复
热议问题