Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
“Unix screenshots” can mean two different targets on a Windows PC: the Windows desktop itself, or a Linux display running inside WSL. The correct Python library and display backend depend on which screen you need. For the Windows desktop, run Python with Windows and use PyAutoGUI or MSS. For a Linux GUI in WSL, run the code in the Linux environment and make sure its X11 or Wayland display is available. A Linux screenshot call does not automatically capture the Windows host desktop.
First decide which display you are capturing
The search phrase “How to Take Unix Screenshots from Python on a Windows PC” combines an operating system with a Unix-like environment. Turn it into a concrete requirement before installing anything:
- Windows desktop: capture the monitors, windows, or regions visible to Windows. Use a Windows Python interpreter.
- Linux/Unix display in WSL: capture a Linux GUI application or display exposed to that WSL environment. Use Linux Python inside WSL and verify the display variables and backend.
- Windows capture started from WSL: treat this as an integration task. WSL can launch Windows executables, but a Linux capture library should not be assumed to see the entire Windows desktop.
Microsoft Learn describes WSL as providing “bidirectional interop between Windows and Linux.” That makes cross-boundary orchestration possible, but it does not turn a WSL display into a Windows desktop capture API.
Recommended Free Tools
Capture the Windows desktop with Python
Option 1: PyAutoGUI for a compact screenshot
PyAutoGUI’s screenshot function returns a Pillow image. Supplying a filename saves it directly, which is enough for a basic full-screen PNG.
#1 Best Overall
- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
- Open PowerShell.
- Install PyAutoGUI into the interpreter that will run your script:
py -m pip install pyautogui
Then create capture_windows.py:
import pyautogui
image = pyautogui.screenshot("screenshot.png")
print(f"saved {image.size} to screenshot.png")
Run it with:
py capture_windows.py
PyAutoGUI requires Pillow for screenshot support. The call captures the desktop visible to that Windows session and writes screenshot.png in the current directory. If you need a particular window or region, arrange the desktop first or use a library with explicit monitor and region APIs.
Option 2: MSS for monitors, regions, and pixel processing
MSS documents separate Windows and GNU/Linux capture backends and exposes monitor and rectangular-region capture. Install it from PowerShell:
py -m pip install mss
This example captures the first monitor reported by MSS:
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →from mss import MSS
with MSS() as capture:
image = capture.grab(capture.monitors[1])
print("captured size:", image.size)
# image contains the captured pixel buffer
capture.monitors[0] represents the combined virtual desktop in MSS’s monitor list; entries such as capture.monitors[1] represent individual monitors when available. To capture a region, pass a dictionary with left, top, width, and height:
from mss import MSS
region = {"left": 100, "top": 100, "width": 800, "height": 600}
with MSS() as capture:
shot = capture.grab(region)
print(shot.size)
MSS is useful when your next step is pixel analysis or when selecting a monitor/rectangle matters more than a one-line save operation. Its documented examples also show conversion to Pillow images for workflows that need Pillow’s file formats and image methods.
Capture a Linux or Unix display inside WSL
What WSL GUI support provides
Microsoft states that WSL supports Linux GUI applications using X11 and Wayland in an integrated Windows desktop experience. The documented prerequisites are WSL 2 and either Windows 11 or Windows 10 build 19044 or later; the page was last updated August 6, 2025, so verify current requirements before deploying. Microsoft also notes that this is not a complete Linux desktop environment.
A Linux screenshot therefore captures the display visible to the Linux session, not automatically every Windows monitor. A headless shell, missing display server, or X11/Wayland mismatch can make a package import successfully while the actual capture fails.
Rank #2
- 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
- 4GB DDR4 System Memory; 128GB Solid State Drive
- 11.6" HD (1366 x 768) Multi-Touch Display
- Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
- Windows 11 Pro
MSS in Linux Python
Install MSS inside the distribution where the Linux GUI runs:
python3 -m pip install mss
On Linux, MSS uses the display identified by DISPLAY by default. Confirm that variable before running your script:
echo $DISPLAY
Then use the same monitor or region API:
from mss import MSS
with MSS() as capture:
shot = capture.grab(capture.monitors[1])
print("Linux display size:", shot.size)
If your setup exposes more than one display or requires a particular backend, select the documented MSS display/backend configuration for that environment. The exact choice depends on whether your GUI is using X11 or Wayland and how WSLg exposes it.
PyAutoGUI on Linux
PyAutoGUI can also capture a Linux display, but its Linux installation instructions identify scrot as a required screenshot utility. Install the package through your distribution’s package manager, then install PyAutoGUI in the Linux Python environment:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchpython3 -m pip install pyautogui
After the display is available, the call is the same:
import pyautogui
image = pyautogui.screenshot("wsl-display.png")
print(image.size)
If scrot is missing, or if no usable display is attached to the process, installation alone will not fix the capture.
Pillow ImageGrab and Linux fallbacks
Pillow’s ImageGrab module provides a direct screen-capture API. Its documentation describes Linux fallback programs—gnome-screenshot, grim, or spectacle—when the stated X11 condition applies and those programs are installed. This is a fallback path, not a guarantee that every Wayland or WSL configuration will work.
Rank #3
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
from PIL import ImageGrab
image = ImageGrab.grab()
image.save("linux-display.png")
Choose the fallback utility that matches the desktop stack available in your distribution. If the display is Wayland-only, an X11-oriented fallback may not help.
Free tools Windows power users keep installed
One-click scans. No signup required.
Starting a Windows capture from WSL
WSL can launch Windows programs from a Linux shell by using the .exe extension. That gives you an integration building block, not a ready-made host-desktop screenshot script. A reliable design is:
- Put the capture code and its dependencies in a Windows Python environment.
- Invoke that Windows script from WSL using the appropriate executable command.
- Write the image to a path that both sides can address, or copy the bytes across the boundary explicitly.
- Validate the result on the specific Windows, WSL, display, and permission combination you deploy.
If the requirement is “capture everything visible on Windows,” run PyAutoGUI or MSS with Windows Python. If the requirement is “capture a Linux GUI launched through WSLg,” run the Linux capture code against that Linux display instead.
Choosing the library and capture model
| Need | Practical choice | Important dependency or limitation |
|---|---|---|
| One full Windows screenshot saved to a file | PyAutoGUI | Pillow is required; use Windows Python. |
| One monitor or a rectangle | MSS | Use the monitor list or a region dictionary; backend differs by operating system. |
| Raw pixels for analysis | MSS | Its grab result exposes pixel data and can be converted to Pillow. |
| Linux display with a simple API | PyAutoGUI or Pillow ImageGrab | Display server must be available; PyAutoGUI documents scrot on Linux. |
| Linux fallback utilities | Pillow ImageGrab | Documented fallbacks include gnome-screenshot, grim, and spectacle under the stated X11 condition. |
There is no established, hardware-independent benchmark here. Documentation timing or one-machine examples should not be treated as a universal speed ranking. Measure your own resolution, monitor count, image format, and processing pipeline if latency matters.
Saving formats, paths, and repeatable scripts
Use absolute paths when a script may be launched from PowerShell, a scheduler, or WSL:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →from pathlib import Path
import pyautogui
output = Path.home() / "Pictures" / "python-capture.png"
output.parent.mkdir(parents=True, exist_ok=True)
pyautogui.screenshot(str(output))
print(output)
PNG preserves lossless pixels and is a sensible default for UI evidence. Pillow can save other formats when the image mode and filename extension are compatible. For repeated captures, avoid overwriting the same file unintentionally by adding a timestamp or sequence number, and close or release capture objects promptly in long-running jobs.
Troubleshooting
“The package imports, but capture fails”
Check the target first. A Windows Python process cannot use a Linux display merely because WSL is installed, and Linux Python does not automatically capture the Windows host desktop. Run the library in the environment that owns the screen.
Rank #4
- EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
- 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
- RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
- ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
- LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
PyAutoGUI reports a missing Pillow or screenshot utility
Install Pillow through the same interpreter used to run the script. On Linux, install the documented scrot dependency and ensure it is on the process’s PATH.
MSS returns the wrong monitor or size
Print capture.monitors and inspect the entries instead of assuming monitor numbering. Use an explicit region when you need a stable rectangle. Mixed scaling, rotated displays, and virtual-desktop coordinates can make the values differ from what you expect visually.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Linux reports no display
Inspect DISPLAY, confirm a GUI application can run in that WSL session, and determine whether the session uses X11 or Wayland. A non-interactive shell, service account, or headless process may not have access to the user’s display.
ImageGrab falls back but still cannot capture
Install the fallback utility appropriate to your Linux desktop and verify the documented X11 condition. Installing all utilities blindly will not solve a backend mismatch.
WSL invocation creates a file you cannot find
Use an explicit Windows or mounted path and print it from both sides. Remember that a Linux path and a Windows path are not interchangeable strings; make the transfer step part of your design.
Capture is blank or blocked
Some protected, minimized, elevated, remote, or hardware-accelerated surfaces may not expose pixels to ordinary desktop capture. Test the exact application and session type. This is separate from whether Python itself is installed correctly.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsOr skip the browser setup
If what you really need is a screenshot of a web page rather than the local desktop, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF, so you do not need to configure a browser display in Windows or WSL.
Best Value
- WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
- 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
- 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
- CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
- LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
With the documented API, supply your access key and target URL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for all parameters. The equivalent Python and Node.js calls are:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
const data = Buffer.from(await res.arrayBuffer());
require('fs').writeFileSync('shot.webp', data);
ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status. Its MCP server lets Claude, Cursor, and other MCP clients use take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000 shots. Sign up for the free plan.
Operational and cost notes
- Local libraries: PyAutoGUI, MSS, and Pillow run on your machine; cost is generally the time and storage of your own environment rather than a per-image service charge.
- Display access: scheduled tasks, services, locked sessions, remote desktops, and multiple-user Windows sessions can expose a different screen—or no screen—to Python.
- Reliability: identify the target environment, print the selected monitor or output path, and test after display, scaling, or WSL updates.
- Web-page automation: an API avoids maintaining browser drivers and desktop-display plumbing, while still giving you explicit response headers for billing and page verdicts.
FAQ
Can Linux Python in WSL capture my entire Windows desktop?
Not by assumption. Use Windows Python for the Windows desktop, or build and validate a deliberate cross-boundary invocation.
Which library should I start with?
Use PyAutoGUI for the shortest full-screen script. Start with MSS when monitor selection, rectangular regions, or pixel processing is central.
Is WSL a full Linux desktop?
No. Microsoft describes WSLg as an integrated way to run Linux GUI applications, not a complete Linux desktop environment.
Can these examples capture a web page without opening a local browser?
They capture an available desktop display. For server-side web-page images or PDFs, use a web screenshot API such as ScreenshotNeo instead.
Frequently Asked Questions
Can I capture a specific Linux window in WSL?
The documented examples cover displays, monitors, and rectangles. Window-specific capture depends on the Linux desktop/backend and is not guaranteed by these basic calls.
Why does my script work interactively but fail in Task Scheduler?
The scheduled process may run without the interactive user’s display, permissions, or environment variables. Configure and test the session explicitly rather than assuming it sees the logged-in desktop.
The Bottom Line
Run PyAutoGUI or MSS with Windows Python for the Windows desktop; run Linux capture code only when WSL exposes the Linux display you actually need. Verify the display backend, monitor coordinates, dependencies, and execution session before treating a successful import as a successful screenshot.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

