首页 > 编程语言 > 详细

Python PIL库安装

时间:2018-05-09 11:48:45      阅读:184      评论:0      收藏:0      [点我收藏+]

由于需要使用Python操作图片,想使用sudo pip install PIL引入PIL(Python Imaging Library)库,但是结果如下:

could not find a version that satisfies the requirement PIL.(form versions:)
No matching distribution found for PIL.

这个提示很费解,只能去找度娘了,原来已经用Pillow代替了PIL,在使用方面没有不同,API都是相同的。真是个挨千刀的,提示信息里怎么不告诉我们这些刚学Python的小白呢,还得白忙活半天。既然这样那就老老实实安装Pillow吧。但是又发现Pillow需要依赖multiprocessing,所以必须先安装multiprocessing。命令如下:

sudo pip install multiprocessing

接着再执行如下命令:

sudo pip install Pillow

引入模块要按照下面的方式写(注意大小写)
第一种:from PIL import Image
第二种:from PIL.Image(用这种方式时,下面使用时也得写成PIL.Image.open(‘1.png‘),或者可以在引入时修改下模块名,如from PIL.Image as image)

引入之后就可以正常使用了。

Python PIL库安装

原文:https://www.cnblogs.com/suxianglun/p/9013043.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!