I'm running Python 2.7.12 installed with homebrew on my Mac OS X 10.11 and trying to use pyautogui. However, it keeps crashing ("Python quit unexpectedly.") when I try to run it as an imported module in another .py file. Like this:
# gui.py
import pyautogui
def myfunction():
pyautogui.click( 100 , 200 )
if __name__ == '__main__':
myfunction()
# another.py
import gui
gui.myfunction()
It works fine when I run "python gui.py" alone. But when I try to run another.py, even without calling any function from gui.py, Python would crash every single time. After narrowing it down with line by line elimination, it seems it's the
import pyautogui
that caused the crash. Any idea why? All I know is when included as a module, a .pyc file is created. I tried to delete it and run again, but didn't do anything.
Thank you!
I got it! This is because I'm importing pyscreenshot, and there is a conflict between it and pyautogui. Both use pillow and probably have some different reference to it that I'm not knowledgeable enough to tell. But as soon as I removed the pyscreenshot, pyautogui is running normal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With