13

I'm trying to use pyautogui's screenshot functions with Python 3.6.5 on OSX 10.11.

>>> import pyautogui
>>> image = pyautogui.screenshot()

I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyscreeze/__init__.py", line 331, in _screenshot_osx
    im = Image.open(tmpFilename)
NameError: name 'Image' is not defined

My understanding is that pyscreeze is failing to get the name Image from Pillow for some reason. I tried to update the pyautogui (it was up to date), then reinstall the pyautogui, which carries all its dependencies including pyscreeze and Pillow along with it.

I found this question with the same issue, but the fix that worked there (reinstalling) isn't working for me.

Sergei Danielian
  • 4,938
  • 4
  • 36
  • 58
aacampbell
  • 131
  • 1
  • 4
  • 1
    SOLVED: I solved this by downgrading Pillow from 5.1.0 to 5.0.0 and pyscreeze from 0.1.14 to 0.1.13. Guess something got introduced into one of them that messed up the pyautogui functionality. – aacampbell May 18 '18 at 01:58

2 Answers2

8

do

pip install Pillow==0.1.13

since Image is module from PIL

Prajot Kuvalekar
  • 5,128
  • 3
  • 21
  • 32
  • In my case, I need to add exactly this package and then the error disappeared. Thanks. – Martin Aug 08 '22 at 12:58
  • This no longer works: ```ERROR: Could not find a version that satisfies the requirement Pillow==0.1.13 (from versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 2.0.0, 2.1.0, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2,...) ERROR: No matching distribution found for Pillow==0.1.13 ``` – Travasaurus Aug 30 '22 at 03:04
  • downgrade your python and then try this @ https://stackoverflow.com/users/6598627/travasaurus – Prajot Kuvalekar Aug 30 '22 at 04:17
1
pip3 uninstall pyautogui
pip3 uninstall Pillow

then reinstall the modules and restart you editor.

Taku
  • 31,927
  • 11
  • 74
  • 85
andream
  • 33
  • 4