aacampbell
aacampbell

Reputation: 131

Pyautogui screenshot - NameError: name 'Image' is not defined

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.

Upvotes: 13

Views: 11250

Answers (2)

andream
andream

Reputation: 33

pip3 uninstall pyautogui
pip3 uninstall Pillow

then reinstall the modules and restart you editor.

Upvotes: 1

Prajot Kuvalekar
Prajot Kuvalekar

Reputation: 6618

do

pip install Pillow==0.1.13

since Image is module from PIL

Upvotes: 8

Related Questions