要想在python中操作图片,比如引入PIL(Python Imaging Library)库。
在python安装第三库时,可以使用工具easy_install或pip,我推荐使用pip这个工具。针对mac电脑,pip是不需要手动安装,在命令行可以直接输入pip验证是否已经安装。
若是pip没有安装,可以使用命令sudo easy_install pip(保证mac连接互联网)
安装pip之后,可以使用命令sudo pip install PIL来安装操作图片的模块了。
若是安装正常,那皆大欢喜了。在我电脑安装时,却出现了问题。
could not find a version that satisfies the requirement PIL.(form versions:)
No matching distribution found for PIL.
这个是说明PIL已经找不到,其实现在已经用Pillow代替了PIL,在使用方面没有不同,API都是相同的。
既然如此,咱们就直接安装Pillow模块吧,执行sudo pip install 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开发用的是64位,但官网上没有64位的PIL安装。后来找到个安装包,完全可用,已测试。感谢开发者,先分享给大家
此文件包含python2.7,pIL1.17,pytesser_v0.0.1,经过本人验证可用
python PIL包,用于图片解析,windows安装版exe.亲自测试
资源分类:Python库 所属语言:Python 资源全名:weditor-0.0.4.dev7.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
OpenCV转换成PIL.Image格式: import cv2 from PIL import Image import numpy img = cv2.imread("plane.jpg") cv2.imshow("OpenCV",img) image = Image.fromarray(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) image....
但是有时候也会出现在线安装失败的情况,如下图安装PIL模块时报错: 这时候可以采取离线安装的方式; 一、首先下载离线安装包 PIL官方版不支持py3,不过有非官方那个的替代品pillow,地址:http://www.lfd.uci.edu/~...
python pil for win64 python2.7,下载解压,之后安装:pip install Pillow,之后就可以用from PIL import ImageGrab
PIL Win64 Python2.7 需要用PIP安装。看到有人卖5分,看不下去了。
python2.7 库PIL在apache2.4+django1.3中发布时。 PIL出现: The _imaging C module is not installed 错误 请安装这个版本的PIL库
Python第三方图像处理库PIL
Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块Python PIL1.1.7 模块...
python的图形库PIL的windows 64 版本的库,本应该是免费的,但是好像没有免费的选项上传。
python2.7 pil selenium hook
from PIL import Image 方法一:在使用OpenCV读取图片的同时将图片转换为灰度图: img = cv2.imread(imgfile, cv2.IMREAD_GRAYSCALE) print(cv2.imread(imgfile, cv2.IMREAD_GRAYSCALE)结果如下:) print('大小...
因为课程需要,本人花了一下午时间制作的PPT,查找了许多资料,结合自己特学期所学到理解来制作的PPT,适用于小组模块展示,也适用于个人演示。
from PIL import Image, ImageDraw, ImageFont image= Image.new('RGB', (559, 320),(255,255,255)) draw = ImageDraw.Draw(image) # draw.text() font = ImageFont.truetype("arial", 40, encoding="unic") # 设置...
python安装32位的 PIL-1.1.7.win32-py2.7.exe
PILwin32 For python 2.7这是PIl 的32位版本下载。同样的还有64位版本的下载,清参考博客的另一个资源。
用于解决windows下,"The _imagingft C module is not installed"错误。