weditor报错
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
解决办法
卸载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