Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 746
aacampbell Avatar asked May 17 '18 18:05

aacampbell


People also ask

What does Pyautogui Screenshot return?

The screenshot() Function Calling screenshot() will return an Image object (see the Pillow or PIL module documentation for details). Passing a string of a filename will save the screenshot to a file as well as return it as an Image object.

How can I make my Pyautogui screenshot faster?

Start by putting the cursor at the top left of the region you'd like to capture, then press enter. Next move to the bottom right of the region you're looking for, and again, press enter. Hope this helps!


1 Answers

do

pip install Pillow==0.1.13

since Image is module from PIL

like image 176
Prajot Kuvalekar Avatar answered Sep 22 '22 00:09

Prajot Kuvalekar