pip3安装pyautogui失败,错误代码为1 Mac OS

时间:2016-01-28 23:41:08

标签: python macos python-3.x python-3.5 pyautogui

我尝试安装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

4 个答案:

答案 0 :(得分:3)

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

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

由于代码不是由我编写的,请使用此解决方法,风险自负。

答案 1 :(得分:1)

已解决

执行命令

1. sudo pip3 install pil

2. sudo pip3 install Pillow

3. sudo pip3 install pyautogui

宾果!安装没有错误

答案 2 :(得分:1)

如果你像我一样并没有成功安装pyautogui,我就采取以下措施解决问题:

  1. 从Mac App Store安装Xcode。这是安装PyObjC的要求。可以找到详细信息here
  2. sudo pip3 install pyobjc-core
  3. sudo pip3 install pyobjc
  4. sudo pip3 install Pillow
  5. sudo pip3 install pyautogui
  6. 第2步,第3步和第5步详细here

    第4步描述了here,另一个Stackoverflow帖子。

答案 3 :(得分:0)

在macOS High Sierra(10.13.4)上为我工作的一系列步骤:

  • 从AppStore安装Xcode

  • 激活虚拟环境(如果需要)

  • pip3安装pyobjc-core

  • pip3安装pyobjc-framework-Quartz

  • pip3安装映像

  • pip3安装pyautogui