安装Python的Pillow库可以通过以下几种方法:
1. 使用pip安装Pillow:
pip install Pillow
2. 如果遇到安装问题,可以尝试使用国内镜像源加速下载:
pip install -i https://pypi.doubanio.com/simple/ pillow
3. 对于特定版本的Python,可能需要指定Python的安装路径:
pip install --target=d:\python\lib\site-packages pillow
4. 安装完成后,可以通过以下代码测试Pillow是否安装成功:
from PIL import Image
image = Image.open("example.jpg")
print("图片尺寸:", image.size)
image.show()