glitchassassin / lackey

Lackey - Graphical desktop automation with Python
MIT License
616 stars 75 forks source link

Missing dependency on Mac for python3? #146

Closed zh2eou closed 5 years ago

zh2eou commented 5 years ago

I tried to follow the setup steps using python3.5, however when I try to import Lackey it gives me this error:

>>> import Lackey
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'Lackey'
>>> import lackey
Traceback (most recent call last):
  File "/Users/zh2eou/qae/test/.venv/lib/python3.5/site-packages/lackey/__init__.py", line 8, in <module>
    import Tkinter as tk
ImportError: No module named 'Tkinter'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/zh2eou/qae/test/.venv/lib/python3.5/site-packages/lackey/__init__.py", line 12, in <module>
    import tkinter as tk
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tkinter/__init__.py", line 35, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'

After some reason, I found that I had to use MacPorts to install the py35-tkinter package fix that issue. However, even afterwards I seem to get a warning about it not running in Administrative mode:

>>> import lackey
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/lackey/InputEmulation.py:8: DeprecationWarning: The mouse sub-library is deprecated and will be removed in future versions. Please use the standalone package `mouse`.
  from keyboard import mouse
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/keyboard/__init__.py", line 292, in listen
    _os_keyboard.listen(self.direct_callback)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/keyboard/_darwinkeyboard.py", line 430, in listen
    raise OSError("Error 13 - Must be run as administrator")
OSError: Error 13 - Must be run as administrator

>>>
glitchassassin commented 5 years ago

The "run as administrator" error is due to the listener for the Ctrl+Shift+C keyboard shortcut to cancel the script execution. On Mac, that requires privilege escalation. If you aren't using the keyboard shortcut, you can safely ignore the error!

zh2eou commented 5 years ago

Ok, good to know. I tried out some scripts and it looked like they were working fine even with the error.

Also, looks the tkinter issue was due to using MacPorts python instead of the built in Apple python.