Python怎么安装pillow离线,Python怎么安装pandas库

这篇文章主要介绍了Python怎么安装pillow离线,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。

PIL(Python Imaging Library)是Python常用的图像处理库,而Pillow是PIL的一个友好Fork,提供了了广泛的文件格式支持,强大的图像处理能力,主要包括图像储存、图像显示、格式转换以及基本的图像处理操作等。

-----------------------------------------------------------------

0x0. Pillow的注意事项

Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.

Pillow >= 1.0 no longer supports “import Image”. Please use “from PIL import Image” instead.

Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead.

Pillow < 2.0.0 supports Python versions 2.4, 2.5, 2.6, 2.7.

Pillow >= 2.0.0 < 4.0.0 supports Python versions 2.6, 2.7, 3.2, 3.3, 3.4, 3.5

Pillow >= 4.0.0 supports Python versions 2.7, 3.3, 3.4, 3.5, 3.6

0x1. windows安装PIL

PIL安装很麻烦,推荐下载exe直接安装

但现在里面下载链接访问不了,我把32位和64位版本上传到博客园以供下载python编程代码

0x2. windows安装Pillow

pip install Pillow

0x3. linux安装python2.7、pip

sudo apt-get install python

sudo apt-get install python-pip

0x4. linux安装Pillow

在linux里安装PIL不怎么建议,依赖也多,而且会有各种报错。

kali的python默认已安装了Pillow。

在debian/ubuntu里安装Pillow:

sudo apt-get install python-imaging

或者

sudo pip install -I --no-cache-dir -v Pillow

python-imaging安装后的支持import Image

0x5. Pillow wrapper for PIL compatibility

其作者是这样介绍:他项目中也使用Pillow替代了PIL,不过PIL和Pillow的import语句不兼容导致本项目代码修改倒还好说,问题是后来使用的依赖PIL的第三方组件不兼容,我们既不想同时安装Pillow和PIL,又不想修改第三方组件的源代码,所以他写了个很简单的Pillow-PIL,使得依赖PIL的第三方组件不用修改源代码就可以使用Pillow了。安装法子如下:

pip install Pillow-PIL

0x6. PIL一些报错

ImportError:The _imagingft C module is not installed

这个是在windows里安装PIL所报错,建议直接exe安装。

PIL.Image.open() IOError: cannot identify image file

首先检查图片是不是正确的,如果各种检查过还是有问题建议重装PIL

0x7. Pillow报KeyError问题

python

>>> import Image

>>> Image.init()

1

>>> Image.SAVE.keys()

['PCX', 'HDF5', 'EPS', 'MSP', 'XBM', 'WEBP', 'BUFR', 'PPM', 'BMP', 'TGA', 'ICO', 'TIFF', 'JPEG', 'SPIDER', 'GIF', 'GRIB', 'IM', 'FITS', 'PDF', 'WMF', 'MPO', 'PALM', 'JPEG2000', 'PNG']

如果Image.SAVE.keys()输出为空,则说明没有找到save format key,在生成图片时就会报KeyError, 此时就需要把import Image改成from PIL import Image

  • 18
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值