使用Pyinstaller打包的应用程序丢失写入权限

时间:2018-01-15 16:45:19

标签: python python-3.x pyinstaller

我有一个应用程序可下载内容并将其保存到用户指定路径下的硬盘驱动器中。这个应用程序还通过python的shelve模块在自己的目录中创建一个保存文件。一切都运行正常,直到Pyinstaller用于打包应用程序。应用程序打包后,如果它不在“下载”文件夹中,它将不再保存到已指定的路径。

要为此问题添加一个图层,一旦位于Pyinstaller创建的'dist'文件夹中的应用程序包被压缩并解压缩,它将不再创建或保存到shelve创建的保存文件,除非移动应用程序文件夹到下载文件夹。

这是保存下载文件的代码:

def run(self):
    response = requests.get(self.url, stream=True)
        if response.status_code == 200:
            with open(self.filename, 'wb') as file:
                for chunk in response.iter_content(1024):
                    file.write(chunk)

加载保存文件的代码:

@classmethod
def load_pickled_state(cls):
    with shelve.open('save_file', 'c') as shelf:
        # load items

它使用Pyinstaller的一个目录选项打包。我检查了文件夹属性,他们告诉我我有写权限。

为什么使用Pyinstaller打包应用程序会影响写入权限,为什么压缩和解压缩可执行包会影响这些权限呢?

0 个答案:

没有答案