Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Pillow was built without XCB support"

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.

like image 695
abyssmu Avatar asked May 01 '20 04:05

abyssmu


People also ask

How do I know if pillow is installed?

Step 2: To check if PIL is successfully installed, open up the python terminal by typing python3 in the terminal. This will open up the python3 interactive console now type the following command to check the current version of the PIL. This will output the currently installed version of the PIL.


1 Answers

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
like image 179
abyssmu Avatar answered Oct 05 '22 05:10

abyssmu