Python 可执行文件提取器

Python files extractor on executable

我已经用 python pyinstaller 构建了一个可执行文件,需要 当我执行它具有的文件时,将一些文件保留在可执行文件中 将其他文件提取到特定路径,如安装 特定文件夹中的包。

我做了以下事情

  pyinstaller -F --add-data 'installation.zip:installation.zip' --onefile

但我不知道如何将可执行文件中的 zip 文件提取到 目的地。

我使用以下代码

创建了 exe
pyinstaller -F --add-data "installation.zip;installation" phpfilescopy_extract.py --console --onefile

I have done extracting the zip file using this following code. sys._MEIPASS - gives the temporary exe extraction path that i used to locate the zip files and extracted from the path

def excute(self):

    global src
    #source = src
    dst = 'd:/destination'
    # sys._MEIPASS - gives the temporary exe extraction path that i used to locate the zip files and extracted from the path
    source = sys._MEIPASS + "/installation/installation.zip"


    if os.path.exists(dst):
        if source.endswith('.zip'):
            file_zip = zipfile.ZipFile(source)
            file_zip.extractall(dst)
            QMessageBox.about(self, "Title", "all file's extracted")
        else:
            QMessageBox.about(self, "Title", "failed extract file")
    else:
        QMessageBox.about(self, "Title", "path not vialed ")