pip install pyautogui
pip install pillow
pip install opencv-python
# 我安装的版本信息
C:\Users\gsp>pip list
Package Version
------------- --------
MouseInfo 0.1.3
numpy 1.23.5
opencv-python 4.6.0.66
Pillow 9.3.0
pip 22.3.1
PyAutoGUI 0.9.53
其实就是写了个配置文件。我的是:C:\Users\gsp\AppData\Roaming\pip\pip.ini
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
pip install pyautogui
# 如果临时从国内源安装
pip install pyautogui -i https://pypi.tuna.tsinghua.edu.cn/simple
File "C:\Users\gsp\Desktop\XXX.py", line 34, in getlocation
location = pyautogui.locateCenterOnScreen(img, confidence=0.9)
File "C:\all_software\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File "C:\all_software\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 207, in locateCenterOnScreen
return pyscreeze.locateCenterOnScreen(*args, **kwargs)
File "C:\all_software\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 413, in locateCenterOnScreen
coords = locateOnScreen(image, **kwargs)
File "C:\all_software\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 372, in locateOnScreen
screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
File "C:\all_software\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 144, in wrapper
raise PyScreezeException('The Pillow package is required to use this function.')
pyscreeze.PyScreezeException: The Pillow package is required to use this function.
pip install pillow
File "C:\Users\gsp\Desktop\XXX.py", line 34, in getlocation
location = pyautogui.locateCenterOnScreen(img, confidence=0.9)
File "C:\all_software\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File "C:\all_software\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 207, in locateCenterOnScreen
return pyscreeze.locateCenterOnScreen(*args, **kwargs)
File "C:\all_software\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 413, in locateCenterOnScreen
coords = locateOnScreen(image, **kwargs)
File "C:\all_software\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 373, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File "C:\all_software\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 353, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
File "C:\all_software\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 253, in _locateAll_python
raise NotImplementedError('The confidence keyword argument is only available if OpenCV is installed.')
NotImplementedError: The confidence keyword argument is only available if OpenCV is installed.
由于opencv-python依赖numpy,所以会自动安装numpy
pip install opencv-python