python weditor报错[Errno PIL.Image.open IOError]

python weditor Dump Hierarchy报错

weditor正常启动之后,报如下错误
[W 220907 10:05:35 api:40] [Errno PIL.Image.open IOError] cannot identify image file <_io.BytesIO object at 0x000002A4B8713F68>, retrying in 0.5 seconds...
[W 220907 10:05:35 api:40] [Errno PIL.Image.open IOError] cannot identify image file <_io.BytesIO object at 0x000002A4B9692678>, retrying in 0.6 seconds...
[W 220907 10:05:36 api:40] [Errno PIL.Image.open IOError] cannot identify image file <_io.BytesIO object at 0x000002A4B9692678>, retrying in 0.7 seconds...
[W 220907 10:05:37 api:40] [Errno PIL.Image.open IOError] cannot identify image file <_io.BytesIO object at 0x000002A4B9692678>, retrying in 0.7999999999999999 seconds...
Traceback (most recent call last):
  File "D:\ProgramFiles\Python37\lib\site-packages\uiautomator2\__init__.py", line 856, in screenshot
    return Image.open(buff).convert("RGB")
  File "D:\ProgramFiles\Python37\lib\site-packages\PIL\Image.py", line 3031, in open
    "cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000002A4B9692678>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\ProgramFiles\Python37\lib\site-packages\weditor\web\handlers\page.py", line 208, in get
    d.screenshot().convert("RGB").save(buffer, format='JPEG')
  File "D:\ProgramFiles\Python37\lib\site-packages\weditor\web\device.py", line 33, in screenshot
    return self._d.screenshot()
  File "C:\Users\zhuling01\AppData\Roaming\Python\Python37\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "D:\ProgramFiles\Python37\lib\site-packages\retry\api.py", line 74, in retry_decorator
    logger)
  File "D:\ProgramFiles\Python37\lib\site-packages\retry\api.py", line 33, in __retry_internal
    return f()
  File "D:\ProgramFiles\Python37\lib\site-packages\uiautomator2\__init__.py", line 858, in screenshot
    raise IOError("PIL.Image.open IOError", ex)
OSError: [Errno PIL.Image.open IOError] cannot identify image file <_io.BytesIO object at 0x000002A4B9692678>
[W 220907 10:05:38 web:2243] 430 GET /api/v1/devices/android%3A1234567/screenshot (::1) 4786.43ms
[I 220907 10:08:40 web:2243] 200 GET /cdn.jsdelivr.net/bootstrap.select/1.12.2/js/bootstrap-select.js.map (::1) 23.93ms
[W 220907 10:08:40 web:2243] 404 GET /sm/98c4fe1475ff7fa99707914bbcf7a87a87e498127d05226c79c02ecdb398a2ec.map (::1) 2.00ms
[W 220907 10:08:40 web:2243] 404 GET /sm/c4fb516b57c7b14d11cfaf4fa0afaed0f1ddf58e3abd674f53baf5ba737fce4a.map (::1) 2.99ms
[W 220907 10:08:40 web:2243] 404 GET /sm/bb3cf831f70040b32884325f643c4614dfa7dd97b797a6a0893f75dea386500b.map (::1) 3.99ms
[W 220907 10:08:40 web:2243] 404 GET /sm/3cea975aadd5bfb84bdba650e7762e04d67701cfefaf8847bc7b8d35ec39cb33.map (::1) 4.99ms

OSError: [Errno PIL.Image.open IOError] cannot identify image file <_io.BytesIO object at 0x000002A4B9692678>

解决办法

卸载uiautomator然后重装,可以通过手动卸载,也可以通过adb命令卸载,命令卸载如下
// 卸载使用adb命令
adb root
adb shell
gwm:/ # pm list package | grep uiautomator
// package:com.github.uiautomator
// package:com.github.uiautomator.test
gwm:/ # pm uninstall com.github.uiautomator
gwm:/ # pm uninstall com.github.uiautomator.test
gwm:/ # pm list package | grep uiautomator
gwm:/ # exit

// 重装使用python命令
python -m uiautomator2 init

然后再打开weditor重新Dump Hierarchy就可以了

// 启动weditor命令
python -m weditor
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值