.exe file opening Powershell Window - python

I made an .exe file using pyinstaller, but when I run the file it opens a PowerShell window as well. I was wondering if there is anyway I can get it to not open so I just have the python program open.
I haven't really tried anything as I don't really know what I'm doing.

When running pyinstaller be sure to use the --windowed argument. For example:
pyinstaller –-onefile myFile.py –-windowed

if you run it from terminal, you can use this command:
start /min "" "path\file_name.exe"

Related

Make an exe file not showing a terminal

I am using "auto py to exe" to create an exe file from my python script. It works quite well, but it opens a terminal once I launch the script... How can I make it to hide / not display the terminal, like a daemon or a back-process?
Pass the --noconsole argument in the "Manual Argument Input" section. Otherwise, the option to do this should be somewhere there as seen here.

How to open a tkinter script that calls a different script within the same directory?

Sorry for the confusing question. I am working on a GUI and backend of a program that takes information from the gmail-api makes it into a text file. The back end and GUI(Tkinter) are working perfectly but through the python3 shell. When I just click on the python script within the directory a black command prompt appears and then disappears.
When I click on a prototype I have of the GUI that does not call another script but a text file, the GUI pops up perfectly.
This is after I used pyinstaller to make it an executable.
My end goal is to make the whole GUI and back end an executable file.
I was wondering if anyone knows why this happens. I think it might be because of it having to call another script...but I am not sure.
Sorry again for the confusing question and wordy explanation.
You want to go to the terminal after you've intalled pyinstaller and run this command:
pyinstaller --onefile --noconsole yourtkinter.py
Explanation:
--onefile : Optional here, more comfortable for tiny tkinter projects.
--noconsole : Will solve your command line opening issue.
Find here more about the pyinstaller package:
https://pyinstaller.readthedocs.io/en/stable/usage.html

Getting pyinstaller .exe program to run from clicking file?

I have a command line based program that I've turned into an executable using PyInstaller. I would like the program to launch a command prompt and run when clicked. Currently I can only get it to run from the command prompt. When I click it, a blank command prompt will open, remain open for a couple of seconds and then close. I'm stuck. Does anyone have any suggestions?
Have you tried the --console flag with pyinstaller?

How to properly close Python exe console program

I'm trying to figure out how to do exit if the program is done with it's work.
What should I use?
I've tried:
sys.exit()
and
os._exit(0)
But none of them worked in exe created by Py2Exe. It works when it is runned as a py script but if I create an exe, those exit commands do nothing.
Use: quit()
In python's command prompt
Use pyinstaller instead of py2exe you will love it :). sys.exit() should work on pyinstaller.
to install
python -m pip install pyinstaller
to build exe in single file
pyinstaller yourscript.py --onefile
to build a gui app w/o console
pyinstaller yourscript.py --noconsole
If you have problem using pyinstaller dont hesitate to ask :)
If you are just using a console window, it will automatically close at the end of your program.
print("Hello World")
input()
If you run the .py file, a terminal window should pop up that says hello world. When you hit enter(the input part) the program will look for another line of code and when it finds none, will close the program and console window.
If you are trying to execute a command from cmd on python just add \c to the command, and it will close after its execution
example os.system(r'cmd /c "C:\Program Files\PATH" -file C:\PATH.exe')

Pyinstaller add icon, launch without console for Mac

This is a really short question. I have created a package for Mac using Pyinstaller and I am mainly trying to add an icon to it. I am also trying to get the program to run without launching the terminal as the user has no interaction with the terminal. Currently I am keeing the following into cmd when running pyinstaller:
python pyinstaller.py --icon=group.ico --onefile --noconsole GESL_timetabler.py
I get the regular package (Unix Executable) and an App. However only the Unix Executable works and the no processes run when I double click the App.
Also, neither the App, nor the Unix Executable, has the icon image displayed. I am sure this is a trivial problem with my command to pyinstaller, but I am having difficulty figuring out the mistake. Could someone help me fix the instructions above? Thank you!
You must have group.icns file for app in Mac OS
Try using --windowed instead. As far as I can tell they're the same thing, but it might do the trick.
As for icons, I've only gotten that to work on console windows. It just doesn't carry over to my main GUI window.

Categories