我尝试安装autogui python扩展:

pip3 install pyautogui

并且此安装尝试导致以下错误消息:
Collecting pyautogui
  Using cached PyAutoGUI-0.9.33.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui/setup.py", line 6, in <module>
        version=__import__('pyautogui').__version__,
      File "/private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui/pyautogui/__init__.py", line 110, in <module>
        from . import _pyautogui_osx as platformModule
      File "/private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui/pyautogui/_pyautogui_osx.py", line 4, in <module>
        import Quartz
      File "/usr/local/lib/python3.5/site-packages/Quartz/__init__.py", line 5, in <module>
        import objc
      File "/usr/local/lib/python3.5/site-packages/objc/__init__.py", line 18, in <module>
        _update()
      File "/usr/local/lib/python3.5/site-packages/objc/__init__.py", line 15, in _update
        import objc._objc as _objc
    ImportError: dlopen(/usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so, 2): Symbol not found: _PyObject_REPR
      Referenced from: /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so
      Expected in: flat namespace
     in /usr/local/lib/python3.5/site-packages/objc/_objc.cpython-35m-darwin.so

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/00/zcr6mkx90hg7kr4x_ks6nhhw0000gn/T/pip-build-edy15oyn/pyautogui

我的Mac OS版本是OS X El Capitan 10.11.3,我的Python3版本是3.5.1,我的pip3版本是pip 8.0.2。

在Stackoverflow(Cannot install pip install pyautogui, error code 1)上似乎也有类似的问题,但此修复方法不适用于我的问题;我已经安装了“枕头”。另外,我已经阅读了文档(https://pypi.python.org/pypi/PyAutoGUI),并安装了pyobjc-core和pyobjc。 Setuptools已安装并且是最新的。

有谁知道如何解决此错误(并安装pyautogui)?我认为该错误可能是由_PyObject_REPR is missing in Python 3.5.1引起的。

最佳答案

我找到了a workaround。 “Kentzo”的这段代码为我解决了这个问题:

pip3 install https://github.com/GreatFruitOmsk/pyobjc-core/releases/download/v3.0.5.dev0/pyobjc-core-3.0.5.tar.gz

由于代码不是我编写的,因此使用此替代方法需要您自担风险。

关于python - pip3 install pyautogui失败,错误代码为1 Mac OS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35074294/

10-17 02:19