Use pyunpack inside an executable file made with pyinstaller in combination with try except

前端 未结 2 1619
孤独总比滥情好
孤独总比滥情好 2021-01-18 17:34

I have a strange behaviour for pyunpack, a package for unpacking, inside an executable.

I want to do the following thing:

I have a .7z type of file whose end

相关标签:
2条回答
  • 2021-01-18 18:06

    The output of print(abspath(".")) when running directly in python is:

    C:\Users\myname\eclipse-workspace-tms\test_unzip_exe
    

    While running with pyinstaller is:

    C:\Users\myname\eclipse-workspace-tms\test_unzip_exe\dist\test
    

    Thus, the archive is not extracted in the dist\test folder.

    Fix this by setting path to return value of abspath(".") instead of hard-coding it to C:\Users\myname\eclipse-workspace-tms\test_unzip_exe

    0 讨论(0)
  • 2021-01-18 18:07

    The problem is, as you found in your 2nd edit, that pyunpack needs patool installed on the target system - which, in turn, requires python.

    To fix this you need to:

    • Use tarballs or zipfiles; shutil supports theses.

    • Or require the end user to have python installed.

    Another way of putting it is that to use pyunpack with pyinstaller, you need python on the target system.

    0 讨论(0)
提交回复
热议问题