【问题标题】:AttributeError: module 'pyautogui' has no attribute 'getWindowsWithTitle'AttributeError:模块“pyautogui”没有属性“getWindowsWithTitle”
【发布时间】:2021-07-20 06:52:09
【问题描述】:

我正在编写一个与浏览器交互的机器人(不要说服我为 Selenium 或 Keyboard 和其他人重写),它给了我一个错误。附近没有名称为 pyautogui 的文件,我尝试将其命名为 main 和 python v3.8、3.9。在每种情况下都收到此错误。 macOS

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/rubicon/objc/ctypes_patch.py:21: UserWarning: rubicon.objc.ctypes_patch has only been tested with Python 3.4 through 3.8. You are using Python 3.9.4. Most likely things will work properly, but you may experience crashes if Python's internals have changed significantly.
  warnings.warn(
Traceback (most recent call last):
  File "/Users/alina/PycharmProjects/ABOBA/main_miner_alienworlds.py", line 183, in <module>
    for i in pyautogui.getWindowsWithTitle('##### #######'):
AttributeError: module 'pyautogui' has no attribute 'getWindowsWithTitle'
import pyautogui

…
for j in pyautogui.getWindowsWithTitle('##### #######'):
    do something

pyautogui 是用 pip3 安装的

【问题讨论】:

    标签: python macos pyautogui


    【解决方案1】:

    你使用了错误的模块!

    https://pypi.org/project/PyGetWindow/是包含getWindowsWithTitle的模块

    【讨论】:

    • 它引发了这个 ImportError: cannot import name 'getWindowsWithTitle' from 'pygetwindow' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pygetwindow/__init__ .py)
    • PyGetWindow 在仅 OSX 的 Windows 上也没有该方法 - OP 需要 OSX
    【解决方案2】:

    不幸的是,从 0.9.53 版开始,pyautogui 的 windows 功能仅适用于 Windows,请参阅以下来源的 https://i.stack.imgur.com/HKtcC.png:- https://automatetheboringstuff.com/2e/chapter20/

    【讨论】:

      猜你喜欢
      • 2018-04-14
      • 2019-02-18
      • 1970-01-01
      • 2020-01-01
      • 2019-07-20
      • 2021-11-05
      • 2021-11-04
      • 2021-02-23
      相关资源
      最近更新 更多