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
Related
root.attributes("-transparentcolor", "white") won't work with a .pyw file extension
Up until yesterday all my tkinter GUIs have been working like they should but two days ago all of them stopped working like I want them to. The line root.attributes("-transparentcolor", "white") has always made the white color transparent, like it should, but now it doesn't work like it used to. It does work properly if I launch the program with a .py file extension but not with a .pyw. Obviously I don't want a console window to open along with all of my programs so this is not something I could just accept. Like I said, this has worked fine up until yesterday.
For the past day I've been doing all kinds of things to try to fix this, I even uninstalled python completely and reinstalled the latest version, but nothing has changed my problem.
I'm on Windows 10 and python 3.9.1 right now (after the reinstall, can't remember what version I had before)
I didn't do a single thing that could've made this happen, I didn't update or change anything before my problem showed up, I simply started my computer in the morning like always.
Does anyone have any clue on what I could try? Could anyone try to do the same thing and see if it works for you?
Code below creates a tkinter window with a transparent background if saved as a .py file, but creates a tkinter window with white background if saved like a .pyw file.
from tkinter import *
root = Tk()
root.config(bg= 'white')
root.attributes('-transparentcolor', 'white')
root.mainloop()
Update:
Hmm... I've discovered something interesting!
If I start my program through cmd prompt with pythonw my problem still appears, but if I do the same thing with a cmd prompt running as administrator it all works like before, I get a transparent background!
Update 2:
I've set pythonw.exe to always run as administrator, and this solves my problem. But if I do that I always get a uac prompt which I never got before, so I haven't fixed my problem, I've just found a tedious workaround.
Allrighty then... I've found a solution, even though I do not like it. I don't have anything against windows or Microsoft, but I really do not like the Microsoft store. But I have to give in, this does solve my problem:
I went and installed python 3.9 from the Microsoft store. I do not know why I did it. I do not know why it helped. I started my .pyw file with the installed program/app called "Python 3.9 (Windowed)" and badaboom, badabing, my problem for some frickin reason, disappeared...
I don't know if this is a viable solution long term (or at all for that matter) but it solves my problem, and after 2 days of continuously smashing my head against the keyboard and wanting to set my pc on fire, I have to accept this as a solution and move on...
Thank u #acw1668 and #martineau for trying to help, I really appreciate it!
Tl;dr:
Download python from Microsoft store and use that program to start the file
Total beginner here. I have just installed Atom for use as an IDE for python along with some python packages. This may seem like a very basic question, but I am unable to find the output window.
For example, I type
print ("Hello World")
and I would expect the output to be
Hello World
which is the case for any other Python compiler i can find online. However, I see "Hello World" nowhere in Atom when I run it. The only thing closest to an output would be the space below that just shows the time it took to complete running. Does python not come with an in-built output window?
I have installed packages that seemed to be what I want such as script_runner and output_panel but all to no avail. Can someone point me to the right direction?
Script_runner does not work for me. I use the Script package. I go to the Packages menu item and click on the Script option in that menu. One of the options is to run the script. When I run a script this way a terminal/Console pane opens at bottom of the editor window with output written there. If you are not getting output your script may not be running.
Be sure your file name ends with .py.
For Atom, one of the easiest ways to run python is atom-python-run
All you need to do is press F5 or F6 in the python file
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 ?
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/
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.