You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tried opening an image using image.show() with a .pyw file.
What did you expect to happen?
Logically, no cmd console should pop up, as the file is no console.
What actually happened?
PIL opens up a console when launching image viewer, presumably Windows Viewer (default viewer).
What are your OS, Python and Pillow versions?
OS: Windows 10/11
Python: 3.12
Pillow: 10.2.0
To Replicate the Issue
Have a file with no console extension: main.pyw
Launch python file outside of an environment, IDE, or a console (cmd). Launch it, for example, from the Windows File Explorer.
fromPILimportImageimg_path='your_image_path.png'# Replace with your image pathimg=Image.open(img_path)
img.show()
Potential Solution
From what I've seen and understood, the issue is caused in ImageShow.py, show_file() line 116 with os.system(self.get_command(path, **options)). This line of code appears to be opening a new console if the file is ran with no console. However, it can be easily fixed by replacing os by subprocess: subprocess.call(self.get_command(path, **options), shell=True, creationflags=subprocess.CREATE_NO_WINDOW) (has been tested and works).
The text was updated successfully, but these errors were encountered:
What did you do?
Tried opening an image using
image.show()
with a.pyw
file.What did you expect to happen?
Logically, no cmd console should pop up, as the file is
no console
.What actually happened?
PIL opens up a console when launching image viewer, presumably Windows Viewer (default viewer).
What are your OS, Python and Pillow versions?
To Replicate the Issue
Have a file with no console extension:
main.pyw
Launch python file outside of an environment, IDE, or a console (cmd). Launch it, for example, from the Windows File Explorer.
Potential Solution
From what I've seen and understood, the issue is caused in
ImageShow.py
,show_file()
line 116 withos.system(self.get_command(path, **options))
. This line of code appears to be opening a new console if the file is ran with no console. However, it can be easily fixed by replacingos
bysubprocess
:subprocess.call(self.get_command(path, **options), shell=True, creationflags=subprocess.CREATE_NO_WINDOW)
(has been tested and works).The text was updated successfully, but these errors were encountered: