1QuickQuestion
1QuickQuestion

Reputation: 11

Why is pyauto gui and Pycharm not working for me?

import pyautogui
pyautogui.PAUSE = 1
pyautogui.FAILSAFE = True

pyautogui.click(274, 783)

I'm running Pycharm on a Mac. I have tried installing pyautogui from the interpreter AND with the terminal via pip3. I'm trying to run a simple test to see if it will do 1 mouse click for me, but responds with:

/Users/user/PycharmProjects/NewContractBuyingMacro/venv/bin/python "/Users/user/PycharmProjects/NewContractBuyingMacro/Buying FD Macro 1.py"
Traceback (most recent call last):
  File "/Users/user/PycharmProjects/NewContractBuyingMacro/Buying FD Macro 1.py", line 3, in <module>
    import pyautogui
  File "/Users/user/PycharmProjects/NewContractBuyingMacro/venv/lib/python2.7/site-packages/pyautogui/__init__.py", line 241, in <module>
    import mouseinfo
  File "/Users/user/PycharmProjects/NewContractBuyingMacro/venv/lib/python2.7/site-packages/mouseinfo/__init__.py", line 100, in <module>
    from rubicon.objc import ObjCClass, CGPoint
  File "/Users/user/PycharmProjects/NewContractBuyingMacro/venv/lib/python2.7/site-packages/rubicon/objc/__init__.py", line 3, in <module>
    from .runtime import (  # noqa: F401
  File "/Users/user/PycharmProjects/NewContractBuyingMacro/venv/lib/python2.7/site-packages/rubicon/objc/runtime.py", line 785
    self.restype, *self.argtypes = ctypes_for_method_encoding(self.encoding)
                  ^
SyntaxError: invalid syntax

I thought it might have something to do with Mac not wanting a program to control the mouse, but now I don't think so. I imagine it's something simple. Any help appreciated.

Upvotes: 1

Views: 1000

Answers (1)

mohit
mohit

Reputation: 11

One possible reason why this issue may occur is because your Python interpreter on PyCharm is an older version (2.7 or older). Changing the interpreter to Python 3 will fix this issue.

The Pyautogui only runs with the latest Python version and they doesn’t have any legacy versions of Python supported. To change the interpreter, navigate to settings > preference > python interpreter, and select the python3 interpreter (Location of interpreter - /usr/bin/python3). If you are not able to change the interpreter, please refer to video tutorials

Upvotes: 1

Related Questions