Pyscreenshot

3.1 · active · verified Thu Apr 16

Pyscreenshot is a Python library (version 3.1) designed for taking screenshots across various operating systems. It acts as a pure Python wrapper around existing backend tools. While often considered 'obsolete' in favor of Pillow's native ImageGrab on Linux/macOS, it remains useful for its flexible backend support, Wayland compatibility, and optional subprocess handling. The library's release cadence is irregular, with the latest major update in March 2023.

Common errors

Warnings

Install

Imports

Quickstart

Captures the entire screen and saves it as a PNG file. You can also specify a bounding box for partial screen captures. Ensure Pillow is installed to save and display images.

import pyscreenshot as ImageGrab
import os

# Grab the entire screen
im = ImageGrab.grab()

# Save image to a file
file_path = "screenshot.png"
im.save(file_path)
print(f"Screenshot saved to {file_path}")

# Optionally grab a specific region (bbox = (left, top, right, bottom))
# im_region = ImageGrab.grab(bbox=(10, 10, 510, 510))
# im_region.save("screenshot_region.png")
# print("Region screenshot saved to screenshot_region.png")

# To display the image (requires an image viewer configured for .show())
# im.show()

view raw JSON →