Using Windows, I have a python program that runs CMD within using subprocess.Popen
. When I run it from python, it works. When I create the executable and run it, it doesn't find the tool I am using (esptool
):
'esptool' is not recognized as an internal or external command,
operable program or batch file.
The command call I have built so far with --add-binary
is as follows:
pyinstaller -F main.py -n "ProgramTest" -i resources/ico/icon.ico --add-binary "C:\\Users\\<my_user>\\AppData\\Local\\miniconda3\\envs\\this_env\\Scripts\\esptool.exe;."
(I have obtained the path to esptool
by running where.exe esptool
. That's the only instance of esptool
that appears.)
Also tried the solution listed here, where they use =
after the flag (--add-binary="..."
) and using lib
as in --add-binary="...;lib"
.
Perhaps it has something to do with my python environments? Maybe I am not adding correctly the executable?
The code to execute my cmd lines is as follows:
import subprocess
def execute(cmd):
popen = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, universal_newlines=True
)
for stdout_line in iter(popen.stdout.readline, ""):
yield stdout_line
popen.stdout.close()
return popen.wait()
My environment:
- OS Name: Microsoft Windows 10 Pro
- Version: Windows 10.0.19045 Build 19045
- miniconda: 23.1.0
- Python (env): 3.10.9
- PyInstaller: 5.8.0
- esptool: 3.1