Showing an image opens a console
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?
- 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.

from PIL import Image
img_path = 'your_image_path.png' # Replace with your image path
img = 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).
Hi. Would you like to create a PR with your solution?
I've created PR https://github.com/python-pillow/Pillow/pull/7791 with your solution, except with subprocess.Popen() instead of subprocess.call(), to prevent blocking.
Hi, thanks for making the PR!