Home>

I'm new to python.
I wrote a program that automatically takes a screenshot of the kindle screen and saves it, but I get an error and it doesn't work.

How can it work? We look forward to hearing from you.

〇 Code

import pyautogui
import time
import os
import datetime

page = 5

span = 1

h_foldername = "output"

h_filename = "picture"

time.sleep (5)

folder_name = h_foldername + "_" + str (datetime.datetime.now (). strftime ("% Y% m% d% H% M% S"))
os.mkdir (folder_name)

for p in range (page):

out_filename = h_filename + "_" + str (p + 1) .zfill (4) +'.png'

s = pyautogui.screenshot ()

s.save (folder_name + "/" + out_filename)

pyautogui.keyDown ('left')

time.sleep (span)

〇 Error message

Traceback (most recent call last):
File "C: \ Users \ cjrr6 \ Desktop \ save_kindle_screen.py", line 29, in
s = pyautogui.screenshot ()
File "C: \ Users \ cjrr6 \ AppData \ Local \ Programs \ Python \ Python39-32 \ lib \ site-packages \ pyscreeze \init.py ", line 134, in wrapper
raise PyScreezeException ('The Pillow package is required to use this function.')
pyscreeze.PyScreezeException: The Pillow package is required to use this function.

〇 Referenced site
Kindle automatic screenshot save program
https://qiita.com/yassyyuki/items/1b70c694cbed3cc54af8

  • Answer # 1

    In error

    The Pillow package is required to use this function

    Because it says, the Pillow package is not installed or cannot be loaded.
    Try reinstalling Pillow with pip.

Related articles