python pip install pil_python抠图与pip install PIL报错

窗口命令pip install PIL(python3.6+selenium——2.53.1+pycharm)

from PIL import Image

from selenium import webdriver

d=webdriver.Firefox()

d.get('http://www.baidu.com')

# 窗口最大化

d.maximize_window()

time.sleep(1)

# 进行全屏截图

d.get_screenshot_as_file('c:\mark666.png')

# 定位需要截图的元素位置

baidu=d.find_element('id','su')

# 获取element的顶点坐标

left=baidu.location['x']

top=baidu.location['y']

# 获取element的宽、高

elementwidth=baidu.location['x']+baidu.size['width']

elementheight=baidu.location['y']+baidu.size['height']

# 打开截图

p=Image.open('c:\mark666.png')

# 使用Image的crop函数,从截图中再次截取我们需要的区域,进行图片剪切

p=p.crop((left,top,elementwidth,elementheight))

# 保存我们需要的的图片

p.save(r'c:\mark6.png')

1548485-20190413163522226-2038585038.png

1548485-20190413163613915-286672103.png

1548485-20190413163627537-1008459566.png

https://www.cnblogs.com/yuanzhoulvpi/p/9028713.html(导入pip install PIL报错参考) 可能是我进行了多次的安装和卸载,我在找着pip后输入pip install PIL报错:

could not find a version that satisfies the requirement PIL no matching distribution found for PIL找着个说要下载pillow,下载进行安装报错,然后就在DOS找着pip的目录下输入pip install wheel ,把下载的Pillow‑5.1.1‑cp36‑cp36m‑win_amd64.whl

拖到C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Scripts 安装python目录的scripts文件夹里,最后在DoS窗口找着pip的目录下输入pip install PIL就成功了。 (多次进行安装卸载selenium可能出现这个问题)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值