当前位置:   article > 正文

解决:ERROR: No matching distribution found for PIL

no matching distribution found for pil

解决:ERROR: No matching distribution found for PIL





背景

在搭建之前的代码环境时,报错:
ERROR: Could not find a wersion that satisfies the requirement PIL(from versions: none)
ERROR: No matching distribution found for PIL



报错问题

ERROR: Could not find a wersion that satisfies the requirement PIL(from versions: none)
ERROR: No matching distribution found for PIL
  • 1
  • 2

截图如下:
在这里插入图片描述



报错翻译

主要报错信息内容翻译如下所示:

ERROR: Could not find a wersion that satisfies the requirement PIL(from versions: none)
ERROR: No matching distribution found for PIL
  • 1
  • 2

翻译:

错误:找不到满足要求PIL的版本(来自版本:none)
错误:找不到与PIL匹配的分布
  • 1
  • 2


报错原因

经过查阅资料,发现是模块名字错了。

附:

PIL即Python Imageing Library,而Pillow是PIL的一个分支。Pillow提供了常见的图像读取和处理的操作,它比opencv更为轻巧,而且可以与ipython notebook无缝集成。

小伙伴们按下面的解决方法即可解决!!!



解决方法

使用正确的名字pillow安装。

修改前:

pip install PIL
  • 1

修改后:

pip install pillow
  • 1

使用Image.open()读取图片存储为一个对象,配合numpy的使用案例如下。

from PIL import Image #导入PIL库
import numpy as np

img = Image.open('../xx.jpg') # 读取图片

imgL = Image.open('../xx.jpg').convert('L') # 读取图片灰度图

onvert('L') # 读取图片灰度图

imgL.show() # 展示灰度图


img.show()  # 展示画布

imgData = np.array(img) # 将对象img转化为RGB像素值矩阵

print(imgData) # 输出所有像素的RGB值

imgN = Image.fromarray(imgData) # 将RGB像素值矩阵转化为对象imgN

imgN.save('xxx.jpg') # 储存为文件xxx.jpg

r ,g ,b = img.split() # 分离通道

img = Image.merge("RGB", (b, g, r)) # 合并通道

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

原图如下:

在这里插入图片描述

灰度图如下:

在这里插入图片描述



今天的分享就到此结束了

欢迎点赞评论关注三连

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/756286
推荐阅读
相关标签
  

闽ICP备14008679号