python安裝pyautogui時遇到Pillow問題


執行   pip install pyautogui

提示:

Could not find a version that satisfies the requirement Pillow>=6.2.1 (from pyscreeze>=0.1.21->pyautogui) (from versions: none)

補充:先試試 pip install pillow

如不行,看下面

參考:https://www.jianshu.com/p/3de67550cea6     ,首先從

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow  下載了 Pillow‑7.1.1‑cp38‑cp38‑win_amd64.whl (我安裝的python3.8  win10是64位)

執行:   

pip install e:\downloads\Pillow-7.1.1-cp38-cp38-win_amd64.whl

然后:

pip install pyautogui

成功。

為了輸入中文,參考https://www.cnblogs.com/zwc--blog/p/11079986.html

還需要pyperclip 

然后,參考https://www.cnblogs.com/ffrs/p/11358308.html和https://blog.csdn.net/wenq_yang/article/details/82910427 做個測試 

另外,還有pywinauto  參考:https://www.cnblogs.com/baihuitestsoftware/articles/9317368.html

順便寫個小例子:打開計算器,然后運行腳本找計算器窗口,輸入1+2=

import pyautogui,time

pyautogui.hotkey('win', 'r')
time.sleep(1)
pyautogui.press('shift')#因為默認中文輸入,所以切換輸入法為英文狀態
pyautogui.typewrite('calc.exe')
pyautogui.press('enter')
time.sleep(3)
pyautogui.press('1')
pyautogui.press('+')
pyautogui.press('2')
pyautogui.press('=')

 補充,考慮輸入法的狀態控制。后來添加了英文鍵盤,並設置熱鍵以切換英文輸入狀態,參考https://jingyan.baidu.com/album/63acb44a7cfea461fdc17e5f.html?picindex=3

識別圖片並點擊  參考:https://www.cnblogs.com/yunlong-study/p/14447093.html

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pyautogui
import time


def zan():
    time.sleep(0.5)    # 等待 0.5 秒
    left, top, width, height = pyautogui.locateOnScreen('zan.png')   # 尋找 點贊圖片;
    center = pyautogui.center((left, top, width, height))    # 尋找 圖片的中心
    pyautogui.click(center)    # 點擊
    print('點贊成功!')


while True:
    if pyautogui.locateOnScreen('zan.png'):
        zan()   # 調用點贊函數
    else:
        pyautogui.scroll(-500)    # 本頁沒有圖片后,滾動鼠標;
        print('沒有找到目標,屏幕下滾~')

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM