Build Multiple .py files into a single executable file using pyinstaller

后端 未结 4 1730
情话喂你
情话喂你 2020-12-28 18:55

I have made a small pyqt application of 5 and 6 .py files.Now I want to build them and compiled them in a single main file.Mean I have to operate them from one main window e

相关标签:
4条回答
  • 2020-12-28 19:26

    Try this:

    pyinstaller --onefile main_app.py
    
    0 讨论(0)
  • 2020-12-28 19:34

    I think the solution is to edit the .spec file and run pyinstaller on the spec file instead of the individual .py files.

    You can find information about adding multiple exes to as single .spec file here: https://pyinstaller.readthedocs.io/en/v3.3.1/spec-files.html#multipackage-bundles

    0 讨论(0)
  • 2020-12-28 19:43

    The way can be creating .dll files with C/C++ or C# and adding to the exe folder. To implement this solution you can check c_types of python as well.

    0 讨论(0)
  • 2020-12-28 19:50

    Suppose you had a file called create.py like

    def square (num)
        return num ** 2 
    

    Another file in the same directory called input.py

    from . import create
    def take_input():
        x = input("Enter Input")
        return create.square(x)
    

    And finally your main.py

    from . import input
    if __name__ == '__main__':
        ip = input.take_input()
    

    You will call the command -

    pyinstaller --onefile main.py
    

    And pyinstaller will import all the dependencies of all the files itself

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