我正在阅读《用 Python 自动化无聊内容》的最后一章 - 第 20 章从安装和导入 pyautogui 开始,但我一直无法完成此操作。我已经能够在 Mac 上安装该模块,但我无法将其作为第三方模块添加到 Mu 编辑器中。这是我尝试将其作为模块添加到 Mu 编辑器时收到的错误:
Collecting pyautogui
Using cached PyAutoGUI-0.9.54.tar.gz (61 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting pygetwindow>=0.0.5
Using cached PyGetWindow-0.0.9.tar.gz (9.7 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting mouseinfo
Using cached MouseInfo-0.1.3.tar.gz (10 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting pymsgbox
Using cached PyMsgBox-1.0.9.tar.gz (18 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting pyobjc-framework-quartz
Using cached pyobjc_framework_Quartz-10.3.2-cp38-cp38-macosx_11_0_universal2.whl (211 kB)
Collecting pyobjc-core
Using cached pyobjc_core-11.0.tar.gz (994 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [2 lines of output]
<string>:18: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
PyObjC: Need at least Python 3.9
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
FINISHED
我已经能够使用以下命令在我的 Mac 上成功安装 pyautogui:pip3 install pyautogui
我正在使用 python3.9 我在 macOS Sequia 15.3.1 上
但是,当我尝试将其作为第三方包添加到 Mu 编辑器时,它会退出并出现上述错误。
我搜索了互联网以寻找答案,并尝试过:
- 重启
- 卸载并重新安装 pyautogui 和 pyobjc
- 以管理员身份安装 pyautogui
- 按照 URL 转到 https://setuptools.pypa.io/en/latest/pkg_resources.htmlm(但说实话我不明白这个页面)。
我希望安装能够顺利完成,以便我可以将其导入 REPL 并使用 pyautogui 进行练习。
我特别困惑为什么它说 PyObjC:至少需要 Python 3.9,即使我正在运行 Python 3.9.6。
请帮忙!