I have made a small PyQt application containing 5-6 .py files. Now I want to build and compile them into a single main file, meaning it has to operate from one main window exe.
My .py files are connected with each other successfully. I have used pyinstaller to make the executable file, but the problem is I built each .py file into its own .exe file. But I want to make a single .exe file through which all the .py files can be used.
How to build all .py files into a single .exe file?
PyInstaller supports making executables for Windows, Linux, and macOS, but it cannot cross compile. Therefore, you cannot make an executable targeting one Operating System from another Operating System. So, to distribute executables for multiple types of OS, you'll need a build machine for each supported OS.
However, PyInstaller bundles compiled Python scripts ( . pyc files). These could in principle be decompiled to reveal the logic of your code. If you want to hide your source code more thoroughly, one possible option is to compile some of your modules with Cython.
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
Try this:
pyinstaller --onefile main_app.py
Use the Command pyinstaller --onefile yourprogramname.py
. Pyinstaller will Automatically import and Compile the Dependency Files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With