python uiautomator2 踩坑教程
1. 安装uiautomator2
pip install -U uiautomator2
2. 安装weditor
D:\limuhao\项目\autotest>pip install -U weditor
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting weditor
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/70/8a/a516d06e8b2788feb569c1ecd690897e68f26e389d8a3ca97db7c77b3ad0/weditor-0.7.0.tar.gz (2.2 MB)
---------------------------------------- 2.2/2.2 MB 5.0 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [22 lines of output]
Error parsing
Traceback (most recent call last):
File "C:\Users\limuhao\AppData\Local\Temp\pip-build-env-vudd5tt6\normal\Lib\site-packages\pbr\core.py", line 105, in pbr
attrs = util.cfg_to_args(path, dist.script_args)
File "C:\Users\limuhao\AppData\Local\Temp\pip-build-env-vudd5tt6\normal\Lib\site-packages\pbr\util.py", line 272, in cfg_to_args
pbr.hooks.setup_hook(config)
File "C:\Users\limuhao\AppData\Local\Temp\pip-build-env-vudd5tt6\normal\Lib\site-packages\pbr\hooks\__init__.py", line 25, in setup_hook
metadata_config.run()
File "C:\Users\limuhao\AppData\Local\Temp\pip-build-env-vudd5tt6\normal\Lib\site-packages\pbr\hooks\base.py", line 27, in run
self.hook()
File "C:\Users\limuhao\AppData\Local\Temp\pip-build-env-vudd5tt6\normal\Lib\site-packages\pbr\hooks\metadata.py", line 25, in hook
self.config['version'] = packaging.get_version(
File "C:\Users\limuhao\AppData\Local\Temp\pip-build-env-vudd5tt6\normal\Lib\site-packages\pbr\packaging.py", line 862, in get_version
version = _get_version_from_pkg_metadata(package_name)
File "C:\Users\limuhao\AppData\Local\Temp\pip-build-env-vudd5tt6\normal\Lib\site-packages\pbr\packaging.py", line 830, in _get_version_from_pkg_metadata
pkg_metadata = email.message_from_file(pkg_metadata_file)
File "D:\python3.10\lib\email\__init__.py", line 54, in message_from_file
return Parser(*args, **kws).parse(fp)
File "D:\python3.10\lib\email\parser.py", line 53, in parse
data = fp.read(8192)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 645: illegal multibyte sequence
error in setup command: Error parsing C:\Users\limuhao\AppData\Local\Temp\pip-install-lgo8rg6p\weditor_e6a86e2c873540a9850da9b2b2fd4597\setup.cfg: UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 645: illegal multibyte sequence
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: python.exe -m pip install --upgrade pip
解决方法:从git上把整个仓库拉下来,再安装
D:\limuhao\项目\autotest>git clone https://github.com/openatx/weditor
Cloning into 'weditor'...
remote: Enumerating objects: 1054, done.
remote: Counting objects: 100% (88/88), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 1054 (delta 68), reused 67 (delta 60), pack-reused 966 eceiving objects: 99% (1044/1054), 2.25 MiB | 16.00 KiB/s
Receiving objects: 100% (1054/1054), 2.26 MiB | 22.00 KiB/s, done.
Resolving deltas: 100% (579/579), done.
继续安装
D:\limuhao\项目\autotest>pip3 install -e weditor
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Obtaining file:///C:/Users/limuhao/weditor
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Installing backend dependencies ... done
Preparing ed