安装Python的Pillow库可以通过以下几种方法:
1. 使用pip安装Pillow:
pip install Pillow
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()
请确保在安装前已经正确安装了Python环境,并且根据你的操作系统和Python版本选择合适的方法。