Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip3 install pyautogui fails with error code 1 Mac OS

I tried installing the autogui python extension:

pip3 install pyautogui

And this installation attempt results in the following error message:

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

My Mac OS version is OS X El Capitan 10.11.3, my Python3 version is 3.5.1, and my pip3 version is pip 8.0.2.

There seems to be a similar question on Stackoverflow (Cannot install pip install pyautogui, error code 1), but the fix does not apply to my problem; I have already installed "pillow". Also, I have read the documentation (https://pypi.python.org/pypi/PyAutoGUI), and installed pyobjc-core as well as pyobjc. Setuptools are installed and up-to-date.

Does anyone have an idea how to fix this error (and install pyautogui)? I think the error might originate, because _PyObject_REPR is missing in Python 3.5.1.

like image 357
Timo Krall Avatar asked Jan 28 '16 23:01

Timo Krall


People also ask

Does Pyautogui work on Mac?

PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2 and 3. To install with pip, run pip install pyautogui .

How do I get Pyautogui on my Mac?

To install PyAutoGUI, install the pyautogui package from PyPI by running pip install pyautogui (on Windows) or pip3 install pyautogui (on macOS and Linux). (On macOS and Linux, pip refers to Python 2's pip tool.)

How do I install pip3 on Mac?

How could I install pip3 on my Mac? To install or upgrade pip, download get-pip.py from the official site Then run the following command: sudo python get-pip.py and it will install the pip for your python version which runs the script.

Why is Pyautogui not working?

The Python "ModuleNotFoundError: No module named 'pyautogui'" occurs when we forget to install the pyautogui module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install pyautogui command.


3 Answers

I found a workaround. This code by "Kentzo" fixed the issue for me:

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

Since the code is not written by me, please use this workaround at your own risk.

like image 177
Timo Krall Avatar answered Sep 23 '22 00:09

Timo Krall


If you are like me and had no success installing pyautogui, here is what I did to fix the issue:

  1. Install Xcode from the Mac App Store. This is a requirement for installing PyObjC. Details can be found here.
  2. sudo pip3 install pyobjc-core
  3. sudo pip3 install pyobjc
  4. sudo pip3 install Pillow
  5. sudo pip3 install pyautogui

Steps 2, 3, and 5 are detailed here.

Step 4 is described here, another Stackoverflow post.

like image 26
Anthony L. Avatar answered Sep 22 '22 00:09

Anthony L.


SOLVED

Run:

1. sudo pip3 install pil

2. sudo pip3 install Pillow

3. sudo pip3 install pyautogui

Bingo! installed without an error

like image 22
Emjey Avatar answered Sep 25 '22 00:09

Emjey