Search code examples
python-3.xpyinstaller

Executable file made using Pyinstaller doesn't start


I want to convert the following sample python program into an executable file:

import os
print(os.getcwd())

To convert it into an executable I have used Pyinstaller:

pyinstaller app.py --onefile

And the EXE file is getting generated in the dist folder, but when I run it, it launches and immediately closes, and the expected print statement is not even displayed.

What could be the issue?


Solution

  • It does prints the statement, but just after printing it the code ends. You can add input() or use time.sleep(seconds) to make your program wait until you press a key or any particular number of seconds respectivly.

    To check if your code(without the advice i have given) prints, start that python file in your command line.