Skip to content
Advertisement

exe file not found while compiled with pyinstaller

I want to execute an exe file from a python file that is compiled using pyinstaller

I’m using the following code:

JavaScript

And I compile it using:

JavaScript

Which creates incluse.exe and If I execute it I get the following error:

JavaScript

What I want it to do is execute the executable.exe that I included, which should come up with a message box.

Advertisement

Answer

You can bundle another binary into your exe with pyinstaller using the --add-binary option.

In your Python script you can then call the exe embedded within your exe by using subprocess.Popen(exe_path). You can use sys._MEIPASS to access the temporary location that the exe will be found at in order to build the path to the exe.

Example

putty_launcher.py

JavaScript

Folder Structure

JavaScript

In the root folder, execute:

pyinstaller --add-binary "binariesputty.exe;binaries" --onefile putty_launcher.py

This will then build an exe from the putty_launcher.py script which can successfully call the version of putty.exe that is embedded within the exe.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement