Windows 10 Python 3.6.5 PyInstaller 3.6 Visual Studio Code
pyinstaller --onefile -n appname index.py
After executing the above, when I executed the exe generated in the dist folder, it worked without problems.
It was annoying that the console screen was displayed, so in the spec file
Change console = True
to console = False
pyinstaller specfilename.spec
And run the regenerated exe file,
failed to execute script index
Pop-up is displayed and the process stops.
As a test, if you write a simple script and generate an exe with console = False
, it will not be reproduced, so
I was worried because I didn't know what was the cause.
In the program I wanted to make into an exe this time, I initially imported it as shown below and called the function.
index.py
import funcs
funcs.func1()
funcs.func2()
funcs.py
import anotherfunc
def func1():
anotherfunc.func3()
otherfunc.py
def func3():
By combining the separate functions into one, as shown below, If you stop importing and using other functions from the destination file, You can now run it even when the console is hidden.
index.py
import funcs
funcs.func1()
funcs.func2()
funcs.py
def func1():
func3()
def func3():
Recommended Posts