【20240917_使用pyautogui模块遇到问题】

1、显示不是pip的问题

note: This error originates from a subprocess, and is likely not a problem with pip.
清理缓存:pip cache purge

2、 网络环境不好的地方都需要使用国内镜像:pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out

pip install 模块名 -i https://pypi.tuna.tsinghua.edu.cn/simple

3、0.9.54版本的pyautogui如果直接使用click函数会报错:

报错:pyautogui.FAILSAFE要设置成False
pyautogui.FAILSAFE=False
pyautogui.click(x=150,y=150,duration=3,clicks=2,interval=0.25,button=‘left’)

4、图像没找到异常:pyscreeze.ImageNotFoundException: Could not locate the image (highest confidence = 0.606)

分析:PyAutoGUI;PyScreeze的一个依赖项在2019年1月6日从版本0.1.18更新到了0.1.19。而且,0.1.19版在找不到终止脚本的图像而不是返回“None”之后,会引发ImageNotFound异常。

你所需要做的就是将PyScreeze从0.1.19降级到0.1.18,pyautogui要使用老的版本0.9.38。就能正常工作了

pip install pyscreeze0.1.18 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pyautogui
0.9.38 -i https://pypi.tuna.tsinghua.edu.cn/simple

5、if isinstance(x, collections.Sequence):

AttributeError: module ‘collections’ has no attribute ‘Sequence’
分析:python3.10以下版本不会报错,问题是在3.10版本中将collections中的部分属性放入了子包abc下,导致python版本太新出现了问题。
解决方法有两种:

(1)将python退回到3.10以下的版本。

(2)例如我的情况需要使用pytorch1.11及以上版本,默认安装的是python3.10,没办法降级。

需要将对应报错的语句进行修改:collections.Sequence 修改为collections.abc.Sequence即可.
我的python环境也是3.10.0,使用第2个方法解决

6、TypeError: cannot unpack non-iterable NoneType object

将QQ程序不被其它遮挡就行了

7、使用click函数clicks设置为2,如果没对python代码使用管理员权限,只会单击1次。

如果使用管理员权限打开,就会单击2次

8、当需要定位的图标不在打开的页面,需要滚动条滚到才能到时,先click函数,再dragTo函数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值