Python PyAutoGUI错误提示求解?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python PyAutoGUI错误提示求解?相关的知识,希望对你有一定的参考价值。

代码与提示如图,请问这是什么意思?如何解决?图片元素文件,怎样Python调用,应该存放在什么位置?

先写一下自己的环境:操作系统windows7 64位,python版本python-3.7.0-amd64,安装方式pip。OK,下面就开始逐条列举所遇问题及解决方法。

1.运行pip install pyautogui后出现如下错误(黄字):

Collecting pyautogui
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /simple/pyautogui/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /simple/pyautogui/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /simple/pyautogui/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /simple/pyautogui/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFI
CATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1045)'))': /simple/pyautogui/
Could not fetch URL https://pypi.org/simple/pyautogui/: There was a problem co
nfirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Ma
x retries exceeded with url: /simple/pyautogui/ (Caused by SSLError(SSLCertVerif
icationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: una
ble to get local issuer certificate (_ssl.c:1045)'))) - skipping
Could not find a version that satisfies the requirement pyautogui (from versio
ns: )
No matching distribution found for pyautogui
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming
the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retrie
s exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1
, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get loc
al issuer certificate (_ssl.c:1045)'))) - skipping

这个问题比较坑,看log应该是https鉴权,于是上网找了各种方法,都不行,重装python,重启电脑,修改电脑时间都不行,最后发现是自己在调式其他东西打开了fiddler,关闭fiddler就好了,这个是被自己坑了。

2.继续运行pip install pyautogui后提示You are using pip version 10.0.1, however version 19.0.1 is available.

这个是pip版本低了,根据提示运行python -m pip install --upgrade pip即可。

3.继续运行pip install pyautogui出现错误:

Using cached https://files.pythonhosted.org/packages/01/ed/56d4a369c6e18f6b239
d9ef37b3222ba308bfebf949571b2611ff7d64f1d/PyGetWindow-0.0.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\80237102\AppData\Local\Temp\pip-install-m1k3v484\pygetwindo
w\setup.py", line 11, in <module>
long_description = fh.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 905: ille
gal multibyte sequence

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\80237102
\AppData\Local\Temp\pip-install-m1k3v484\pygetwindow\

这个错误是安装pyautogui过程中遇到的一个核心错误,是安装PyGetWindow过程中出现的,网上搜了一通,最后试了各种方法,就是降低PyGetWindow版本,默认安装的PyAutoGUI-0.9.41,依赖的是PyGetWindow-0.0.4,就是这个PyGetWindow-0.0.4导致了上述问题,于是网上大神说降低PyGetWindow版本,运行pip install PyGetWindow==0.0.1后安装PyGetWindow成功,然后再运行pip install pyautogui,这次成功了
参考技术A rcxc_pos是None
你看看是不是图片路径有问题或者加载失败(比如没有权限读取文件或访问文件夹)本回答被提问者采纳
参考技术B 用7zip打开这个包,把setup.py中的open语句修改下,添加encoding='utf-8', 或者把‘r'改为'rb'以二进制的方式读取。

以上是关于Python PyAutoGUI错误提示求解?的主要内容,如果未能解决你的问题,请参考以下文章

Pyautogui - 如何输入随机单词或数字(“错误:对象不可迭代”)?

当我尝试使用 pyautogui click 功能运行我的代码时出现错误

python安装pyautogui

为啥 pyautogui.click() 返回类型错误?

PyAutoGUI 定位命令返回错误的图像识别坐标

宽带上网错误提示633是怎么回事啊?求解?