Importing external module in single-file exe created with PyInstaller

后端 未结 2 2050
你的背包
你的背包 2020-12-08 05:55

I am using PyInstaller to create a single-file executable. Is it possible for my script to perform an import such that i) the imported module is imported from the same direc

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 06:18

    Type in Pyinstaller -h. It will give you info about pyinstaller and tell you about --runtime-hook. I presume adding this to the executable should work. There's actually a whole page of documentation for this. Surprised you could not find that.

    Anyway,

    The docs say put in: pyinstaller --additional-hooks-dir=. myscript.py.

    I presume then something like pyinstaller --additional-hooks-dir=C:\pathtofolder myscript.py should work in theory. Yet to test it. Tell us how it goes and what made kinks made it work for you.

    Lastly, if you want to be hipster try integrating cython for speed and obfuscation. Fair warning, cython is not as user friendly as pyinstaller appears to be. I have yet to use it successfully.

提交回复
热议问题