“无法找到 zlib 的头文件或库文件,这是从源代码编译 Pillow 时所需的依赖项”

Kyu*_*jin 8 python pip python-imaging-library pyautogui

我正在尝试使用 pyautogui 运行 Python 程序,但出现问题,因为它告诉我 Pillow 尚未安装。我尝试使用以下命令安装或升级它

\n
pip install Pillow --upgrade \n
Run Code Online (Sandbox Code Playgroud)\n

但没有任何效果。

\n

在文档中,他们说 Pillow 不能与 PIL 共存,因此我们需要卸载它,但我不能,因为它说它尚未安装。

\n

错误是:

\n
The headers or library files could not be found for zlib,\n      a required dependency when compiling Pillow from source.\n
Run Code Online (Sandbox Code Playgroud)\n

并且

\n
Collecting Pillow\n  Using cached Pillow-9.2.0.tar.gz (50.0 MB)\n  Preparing metadata (setup.py) ... done\nBuilding wheels for collected packages: Pillow\n  Building wheel for Pillow (setup.py) ... error\n  error: subprocess-exited-with-error\n\n  \xc3\x97 python setup.py bdist_wheel did not run successfully.\n
Run Code Online (Sandbox Code Playgroud)\n

vps*_*seg 8

你需要zlib-dev。这将安装编译 Pillow 部分所需的标头。

您可能会遇到同样的消息jpeg;为此,您需要该libjpeg-turbo-dev包。


小智 -3

如果你是linux用户你可以这样做

pip install pillow
Run Code Online (Sandbox Code Playgroud)

或者

sudo apt install python3-pil
Run Code Online (Sandbox Code Playgroud)