iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
If PIL.ImageGrab misses monitor 2 in a VirtualBox Linux guest, fix the display path before changing Python: confirm the guest’s X11 or Wayland session, capture monitor 2 with its actual coordinate rectangle, verify Pillow has XCB support, and repair VirtualBox monitor integration and Guest Additions. On Linux, all_screens=True is not the fix; an explicit bbox is the reliable way to target the second virtual display.
Why ImageGrab misses the second VirtualBox monitor
Three layers have to agree:
- Pillow’s backend:
ImageGrab.grab()takes a screen snapshot through X11 support when available. Pillow can fall back tognome-screenshot,grim, orspectacleon Linux when the default X11 grab does not return an image. - The guest display protocol: an X11 session exposes a coordinate space that Pillow can capture directly. Wayland applies different security rules, so the X11 path may fail or return a blank result.
- VirtualBox geometry and integration: the guest must actually expose two virtual monitors, with enough video memory and a working display driver. If monitor 2 is outside the guest’s current desktop rectangle, a correct Python call still captures nothing useful.
A particularly easy mistake is passing xdisplay="". Pillow documents that an empty string disables its Linux screenshot fallback. Use xdisplay=None when you want Pillow to try the fallback utilities.
First check: session type and monitor geometry
Do this inside the VirtualBox guest, not on the host. Record whether the desktop is X11 or Wayland and the variables identifying the active display:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →printf 'session: %sn' "$XDG_SESSION_TYPE"
printf 'DISPLAY: %sn' "$DISPLAY"
printf 'WAYLAND_DISPLAY: %sn' "$WAYLAND_DISPLAY"
Use the guest’s display-settings panel to confirm that two monitors are enabled and to find monitor 2’s rectangle. On X11, xrandr --query (if installed) can show the connected outputs and their offsets. A second monitor is not required to begin at x=0: it may be to the right, to the left, above, or below monitor 1, and it may have a negative coordinate.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Write the rectangle as (left, top, right, bottom). The right and bottom values are exclusive, as with a normal Pillow bounding box. Start with a small region known to be inside monitor 2 if you are unsure of its exact edges.
Verify that Pillow can use X11
Run this check in the same Python environment that runs your capture script:
from PIL import features
print("XCB:", features.check_feature("xcb"))
If it prints False, or Pillow reports that it was built without XCB support, install a Pillow build with XCB capability or use one of the documented Linux screenshot fallbacks. A system Python and a virtual environment can contain different Pillow builds, so check the interpreter that actually launches your application:
Free tools Windows power users keep installed
One-click scans. No signup required.
import sys
from PIL import features
print(sys.executable)
print("XCB:", features.check_feature("xcb"))
Do not treat an XCB failure as a coordinate problem. Repair the Python/Pillow installation first, or deliberately use the fallback path described below.
Capture monitor 2 with an explicit bounding box
Replace the four constants with the rectangle reported by the guest. Keep xdisplay=None so Pillow may use its documented fallback if the X11 grab cannot produce a snapshot.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
from PIL import ImageGrab, features
print("XCB:", features.check_feature("xcb"))
# Replace these values with monitor 2's guest coordinates.
SECOND_LEFT = 1920
SECOND_TOP = 0
SECOND_RIGHT = 3840
SECOND_BOTTOM = 1080
second = ImageGrab.grab(
bbox=(SECOND_LEFT, SECOND_TOP, SECOND_RIGHT, SECOND_BOTTOM),
xdisplay=None,
)
second.save("second-monitor.png")
print("saved", second.size)
If your layout places monitor 2 on the left, values such as (-1920, 0, 0, 1080) may be correct. Do not copy that example unless it matches your guest’s layout.
Capture the complete guest desktop
For a Linux desktop-wide attempt, omit the bounding box and keep the display argument unset:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsfrom PIL import ImageGrab
image = ImageGrab.grab(xdisplay=None)
image.save("virtualbox-desktop.png")
On Windows, Pillow documents all_screens=True for all monitors. That option is documented as Windows-only, so it is not a Linux VirtualBox solution. On Linux, use the guest’s coordinates and bbox.
Repair VirtualBox’s virtual display
Python cannot capture a monitor that the guest does not expose. Shut down the VM when VirtualBox requires it, then inspect Settings > Display > Screen.
Set the monitor count
Set Monitor Count to 2. VirtualBox supports up to eight virtual monitors; they can appear as separate VM windows or map to physical host screens in full-screen or seamless mode. After booting, verify that the guest desktop itself lists two displays.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Allocate sufficient video memory
Increase Video Memory when the second display is black, cannot be enabled, or full-screen mode fails. Required memory rises with color depth, resolution, monitor count, and graphics acceleration. The exact amount depends on those settings, so increase it within the slider’s permitted range rather than assuming one universal value.
Choose a controller supported by the guest
Under Graphics Controller, use the controller appropriate for the guest. Oracle documents that VBoxSVGA and VMSVGA selection requires Guest Additions. A mismatched controller or missing additions can leave the desktop at one monitor, fail to resize, or expose stale geometry.
Repair or update Guest Additions
Guest Additions supply the display drivers and services used for resizing and monitor topology. Oracle recommends keeping the Guest Additions version aligned with the host VirtualBox version.
- In the running VM, choose Devices > Insert Guest Additions CD Image.
- Run the installer supplied for the guest distribution, allowing it to rebuild the kernel modules when requested.
- Reboot the guest. A reboot is especially important after changing VBoxVGA or VBoxSVGA-related display settings so the driver and session service reload.
- Confirm that the desktop now offers two monitors before testing Pillow again.
For VMSVGA Linux guests, VBoxDRMClient receives host resize hints and a desktop helper applies primary-screen and multi-monitor actions. If resizing or monitor 2 remains stale after correcting the installation, restart the guest session after the Guest Additions repair.
Use a screenshot fallback when X11 capture fails
Install at least one utility supported by Pillow’s Linux fallback path: gnome-screenshot, grim, or spectacle. Use your distribution’s package manager and select the utility that matches the session: grim is commonly associated with Wayland compositors, while gnome-screenshot and spectacle are desktop-specific choices.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Then leave xdisplay as None:
from PIL import ImageGrab
# Allows Pillow to invoke its documented Linux fallback if needed.
image = ImageGrab.grab(xdisplay=None)
image.save("fallback-desktop.png")
Passing xdisplay="" does the opposite: it disables that fallback. If you intentionally need a particular X display, use the appropriate display value for the active X11 session, but do not use an empty string as a generic Linux setting.
Validate monitor 1 and monitor 2 separately
Validation distinguishes a bad rectangle from a broken display integration.
- Capture a small, obvious region on monitor 1 and save it.
- Capture an equally sized region on monitor 2 using its explicit
bbox. - Print each returned image’s
sizeand inspect the colors or a known window in both files. - Move the second rectangle in small increments if the image is clipped, shifted, or shows the wrong monitor.
- If both rectangles return blank images, repeat the test after checking XCB, Guest Additions, video memory, and the fallback utility.
A returned image with the expected dimensions but the wrong content usually indicates coordinate topology. A failure before an image is returned points more strongly to the backend, session, or VirtualBox integration.
Troubleshooting by symptom
| Symptom | Likely cause | Fix |
|---|---|---|
| Monitor 2 is absent from the guest settings | VirtualBox Monitor Count is 1, or Guest Additions/display driver is not active | Set Settings > Display > Screen > Monitor Count to 2, repair Guest Additions, and reboot. |
features.check_feature("xcb") is false |
The installed Pillow build lacks XCB support | Install a Pillow build with XCB support, or use a documented fallback utility with xdisplay=None. |
| Capture is black or blank with an X11 session | Wrong display rectangle, insufficient video memory, stale integration, or failed X11 grab | Recheck the rectangle, increase video memory, restart after Guest Additions repair, and test the fallback. |
| Wayland capture fails while X11 examples work | Wayland’s capture path differs from X11 | Use grim or another supported fallback, keep xdisplay=None, or test from an X11 guest session. |
| Only the primary monitor appears | all_screens=True was used on Linux, or the guest desktop has one screen |
Use an explicit second-monitor bbox and verify the VirtualBox monitor count and guest topology. |
| Image is shifted or clipped | Monitor 2 starts at a nonzero or negative coordinate, or the rectangle exceeds the guest desktop | Use the exact (left, top, right, bottom) values from the guest layout and test a smaller region first. |
| Display does not resize after host changes | Guest Additions are missing, mismatched, or their session services are stale | Match Guest Additions to the host version, rebuild modules, reboot, and restart the guest session if necessary. |
| Fallback never runs | xdisplay="" explicitly disabled it, or no fallback utility is installed |
Install gnome-screenshot, grim, or spectacle, then call ImageGrab.grab(xdisplay=None). |
Reliability and performance considerations
- Prefer a targeted
bbox: it transfers fewer pixels than a desktop-wide capture and makes monitor selection deterministic. - Expect larger images to cost more time and memory: two high-resolution displays at higher color depth create substantially more pixel data than one small region.
- Keep topology stable: changing full-screen, seamless mode, scaling, or host monitor arrangement can change guest coordinates. Re-read the rectangle after such changes.
- Separate software and VM failures: first test whether the guest desktop can display monitor 2, then test a fallback utility, then test Pillow. This prevents rewriting code for a VirtualBox configuration problem.
- Use shared clipboard only as a transfer aid: Oracle documents image transfer through the shared clipboard when current Guest Additions are installed. It can move a test screenshot between guest and host, but it does not repair
ImageGrab.
Or skip the browser setup
If the actual goal is a clean screenshot of a web page rather than the local VirtualBox desktop, ScreenshotNeo returns a page image or PDF with one request. It is not a replacement for capturing an arbitrary guest desktop, but it avoids browser and display-session setup for web URLs.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →ScreenshotNeo accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
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)
Node.js
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(`ScreenshotNeo: ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
await Bun.write('shot.webp', data);
See the ScreenshotNeo API documentation for request options. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots, and every feature is available on every plan. Create a free ScreenshotNeo account to try it.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
FAQ
Can ImageGrab capture a monitor that is not attached to a visible VM window?
It can capture only what the guest session exposes in its desktop coordinate space. Confirm that the virtual monitor is enabled and the guest desktop recognizes it; host-side window placement alone does not create guest pixels.
Should I change Python code or VirtualBox settings first?
Check session type, guest geometry, and monitor count first. If monitor 2 is missing from the guest desktop, repair VirtualBox integration before changing the bbox.
Recommended Free Tools
Why does a screenshot utility work when ImageGrab does not?
The utility may be using a protocol-specific path that Pillow’s X11 grab cannot access. Leaving xdisplay=None lets Pillow invoke its documented Linux fallback instead of forcing the failing backend.
Frequently Asked Questions
Can ImageGrab capture a monitor that is not attached to a visible VM window?
It can capture only what the guest session exposes in its desktop coordinate space. Confirm that the virtual monitor is enabled and the guest desktop recognizes it; host-side window placement alone does not create guest pixels.
Should I change Python code or VirtualBox settings first?
Check session type, guest geometry, and monitor count first. If monitor 2 is missing from the guest desktop, repair VirtualBox integration before changing the bbox.
Why does a screenshot utility work when ImageGrab does not?
The utility may be using a protocol-specific path that Pillow’s X11 grab cannot access. Leaving xdisplay=None lets Pillow invoke its documented Linux fallback instead of forcing the failing backend.
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 reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteQuick 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.

