执行python -m uiautomator2 init 报错(原文地址):https://blog.csdn.net/qq_35661796/article/details/84194252
1.先执行python -m uiautomator2 init -e https://pypi.doubanio.com/simple (此条初始化命令必须到UIautomator2目录下执行,目录为:/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages)
2.再执行python -m uiautomator2 init
python uiautomator2 环境搭建(原文地址:https://www.cnblogs.com/yutongX/p/9608729.html
随笔-3 评论-0 文章-1
python uiautomator2 环境搭建
1.安装 uiautomator2 模块
pip install uiautomator2
pip install pillow
2.手机安装uiautomator apk
python -m uiautomator2 init
两种方法连接手机
- wifi
- 通过USB数据线将手机链接电脑
通过wifi连接的话,需要获取手机连接WIFI的IP地址
3.验证脚本
import uiautomator2 as u2
d = u2.connect('192.168.31.234')
print(d.info)
返回手机信息
4.安装weditor
pip install weditor
5.启动 weditor
python -m weditor
weditor启动报错,找不到StringIO模块
解决办法: 修改__main__.py脚本 将“import StringIO”改下面的代码:
try:
from io import StringIO
except ImportError:
from cStringIO import StringIO
接着启动 weditor 启动时提示:No module named ‘cv2’
pip install opencv-python
继续启动 weditor ,会弹出页面 http://atx.open.netease.com/ , 填上手机 的ip地址或者通过USB连接的手机设备号连接, 点击Connect 连接手机, Reload就会显示手机页面