我正在尝试使用 pyautogui 运行 Python 程序,但出现问题,因为它告诉我未安装 Pillow。我尝试使用诸如
之类的命令来安装或升级它pip install Pillow --upgrade
但没有任何效果。
在文档中他们说 Pillow 不与 PIL 共存,所以我们需要卸载它但我不能,因为它说它没有安装。
错误是:
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.
还有
Collecting Pillow
Using cached Pillow-9.2.0.tar.gz (50.0 MB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: Pillow
Building wheel for Pillow (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
我在我的 Mac 上遇到了同样的问题。对我来说,运行以下命令后,它起作用了:
brew install zlib
brew install jpeg
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
如果你是 linux 用户,你可以这样做
pip install pillow
或
sudo apt install python3-pil