Python - Hide Console Mid-Way Through Script - python

Hopefully a simple answer. I have a console python program compiled to exe writing information constantly to the terminal, but half way through the script I'd like the terminal to hide but for the program to continue on hidden.
Is there a quick fix for this or is this more complicated then it seems? Any help is appreciated! Thanks!

I don't think there is a quick fix for this.
You could start without a window, fire up a subprocess with a console, and terminate that process when you want the console to go away.

Related

Black Window in PyInstaller

I'm using PyInstaller to make python-exe's out of my scripts and the exe's work, but every time I execute one of the PyInstaller-exe's a black window pops up. It is pitchblack and looks like a command prompt, but you can't type in it and it disappears as soon as the exe is finished. I want to get rid of it but I don't know how. I've looked on the official website but there is nothing.
Ps: Sorry for eventual spelling- and grammar-mistakes
Yes, that is a console window. Please look again in the documentation at the linked chapter. It is definitely there: https://pyinstaller.readthedocs.io/en/stable/usage.html#windows-and-mac-os-x-specific-options
For some more comments about that, look here: Getting rid of console output when freezing Python programs using Pyinstaller

Python program crashes when opening from installer, but not if script is run from Spyder IDE

something weird is going on. I have created a program with PyQt that when opened in Spyder works flawlessly. However if I create the installer with Pyinstall and run it, the program opens normally but once I click on a cell of a table from the main window, it crashes (so I think it has to do with the mousePressEvent() method?
Is there a way where I can debug it, or know where the error is exactly? Because when it crashes the only thing I get is a message of 'Python has stopped working'.
I do have some try blocks around the code and as I said, when opened from the IDE the whole program works as expected.
Please let me know if you need more info
Thanks
EDIT: For a bit more context, if I put the whole mousePressEvent() method in a try block it will still crash when I click the on a cell of the table
Have you include your external resource (like a image) in PyInstaller with the right path folder ? like in this link and have adapt your code ? https://pythonhosted.org/PyInstaller/spec-files.html#adding-data-files ?

How to run a python program in the background?

How can I make a python program run in the background?
I don't need the console running since all it does is sends me emails with updates once an hour.
Is there a way to do it when I convert it to exe using py2exe?
I am using python 2.7.8.
Also, is there a way to make it open in the boot menu immediately when the computer turns on from the code?
Thank you
If you are asking strictly how to hide the console as part of the py2exe bundling, that's simple. See - Hiding command-line dialog in py2exe
If you are asking how to have a program without a GUI, just build the program in py2exe as above and run it. Unless you have created a GUI, it will run on it's own until it terminates or is terminated.

Python - I can't see my what my error is because the window disappears immediately

I am pretty new to Python and I have been pretty annoyed with this problem. I am not sure if this matters, but I run my .py file with Python 2.7.6 with python installed on my computer, not using it on any online thing or other program. Every time I come across an error, my program works fine until it comes to the error, but the window disappears right before I can possibly read whatever the error said it was... Anyways, I haven't been able to find out what is wrong with my programming, and I am tired of guessing and guessing what is wrong. How can I extend the time so I can read the error message? Or something like that? Thanks
You should run it from command window/terminal instead of double clicking on the file.
Yes, as #shortfellow said, running it from the terminal should work:
python your_file.py
Another tip that helps in Python, if you are having a hard time with errors, is to use iPython for debugging/testing code on the spot. You can give it a try.
http://ipython.org/

Multiple Windows with a Multithreaded pyqt application

I wrote a small multiprocessing application and then wrote a PyQt front end for it. When I run the script by calling it from the command line with Python (or by calling run from the Spyder IDE), it runs exactly as I would expect and works nicely.
But if I try to use Py2Exe to make an executable to give it to a friend, it starts behaving oddly. When the users hits the botton that really starts the process and invokes the multithreading portion, it spawns multiple Qt windows that look like the original. It then essentially locks up. Closing one of the new windows that it spawns causes it to reopen that window. Attempting to close the original generates a message that it is not responding.
I would appreciate any help or suggestions about where to look.
I'm not positive about this without looking at your code, but there are some extra considerations when using Py2Exe with multithreading.
Take a look at this link and maybe it has something to do with your problem.
Someone has a similar sounding issue here

Categories