I’m working on a program that uses ImageGrab in Pillow. I am getting the error mentioned in the title. I notice in the documentation that it says the generic pip install Pillow
doesn’t come with libxcb. I tried installing libxcb with pip install libxcb
, but it apparently doesn’t exist as that. I tried looking around on Google for it, but none of it helped.
If anybody could point me to the specific library that I need to install and commands to run, I’d appreciate it!
I should mention that the python that I’m running is the Windows Store v3.8. I am trying to keep a minimal amount on my SSD and didn’t want a large overhead of stuff I won’t use.
Advertisement
Answer
I finally figured it out. What was going on is that I was trying to use grab(x, y, w, h)
without the bbox=(x, y, w, h)
parameter. Over my two day journey, I did not find a single helpful thing on the Internet. I thought the whole time it was not working because of a missing package or some Linux/Windows conversion dependency.
I hope this helps anybody that comes across this very simple, but agonizing error.
Here is exactly what I was doing:
def grab(x, y, w, h): screen = np.array(ImageGrab.grab(x, y, w, h)) # Throws XCB error ... return screen
Here is the correct code for a Windows platform:
def grab(x, y, w, h): screen = np.array(ImageGrab.grab(bbox=(x, y, w, h))) # Throws no errors # screen = np.array(ImageGrab.grab()) # Alternative that grabs full screen ... return screen