I want to execute an exe file from a python file that is compiled using pyinstaller
I'm using the following code:
import subprocess, os, sys
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
new_path = resource_path("executable.exe")
print new_path
subprocess.Popen(new_path)
And I compile it using:
pyinstaller --add-binary executable.exe;exe -F incluse.py
Which creates incluse.exe and If I execute it I get the following error:
C:\Users\MyUsername\AppData\Local\Temp\_MEI13~1\executable.exe
Traceback (most recent call last):
File "incluse.py", line 16, in <module>
File "subprocess.py", line 394, in __init__
File "subprocess.py", line 644, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified
[21812] Failed to execute script incluse
What I want it to do is execute the executable.exe that I included, which should come up with a message box.