how to use bundled program after pyinstaller --add-binary?

前端 未结 2 693
半阙折子戏
半阙折子戏 2021-02-09 23:22

I am trying to make an executable with pyinstaller, by issuing something like this:

pyinstaller -F --add-binary=\"sometool.exe:.\" myapp.py

The b

2条回答
  •  梦毁少年i
    2021-02-09 23:54

    Try using this according to this question:

    def resource_path(relative_path):
        """ Get absolute path to resource, works for dev and for PyInstaller """
        base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
        return os.path.join(base_path, relative_path)
    

    And than in your app:

    os.popen(resource_path('sometool.exe'))
    

    This should work. I use this everyday :)

提交回复
热议问题