本文介绍了“枕头是在没有 XCB 支持的情况下构建的"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个在 Pillow 中使用 ImageGrab 的程序.我收到标题中提到的错误.我在文档中注意到它说通用的 pip install Pillow 不附带 libxcb.我尝试使用 pip install libxcb 安装 libxcb,但它显然不存在.我尝试在 Google 上四处寻找,但没有任何帮助.

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!

我应该提到我正在运行的python是Windows Store v3.8.我试图在我的 SSD 上保留最少的数量,并且不希望我不会使用的东西产生大量开销.

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.

推荐答案

我终于想通了.发生的事情是我试图在没有 bbox=(x, y, w, h) 参数的情况下使用 grab(x, y, w, h) .在我两天的旅程中,我没有在互联网上找到任何有用的东西.我一直以为是因为缺少软件包或某些 Linux/Windows 转换依赖项而无法正常工作.

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.

这正是我在做的:

def grab(x, y, w, h):
    screen = np.array(ImageGrab.grab(x, y, w, h)) # Throws XCB error
    ...
    return screen

以下是适用于 Windows 平台的正确代码:

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

这篇关于“枕头是在没有 XCB 支持的情况下构建的"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 03:59