close

How to build multiple .py files into a single executable file using pyinstaller?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to build multiple .py files into a single executable file using pyinstaller in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to build multiple .py files into a single executable file using pyinstaller?

  1. How to build multiple .py files into a single executable file using pyinstaller?

    Another file in the same directory called input.py
    from . import create def take_input(): x = input("Enter Input") return create.square(x)

  2. build multiple .py files into a single executable file using pyinstaller

    Another file in the same directory called input.py
    from . import create def take_input(): x = input("Enter Input") return create.square(x)

Method 1

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

Method 2

Try this:

pyinstaller --onefile main_app.py

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read