K
K
Kto Takoi2021-08-28 21:23:28
Python
Kto Takoi, 2021-08-28 21:23:28

How to take a screenshot in python?

how to take a screenshot with python
code like this:
import numpy as np
import pyautogui
import imutils
import cv2
import time

time.sleep(15)

image = pyautogui.screenshot(region=(0,0, 300, 400))

cv2.imwrite( 'pic.png', image)

has this error:
Traceback (most recent call last):
File "E:\Games\python\Projects for python\image\img.py", line 2, in
import pyautogui
File "E: \Games\python\lib\site-packages\pyautogui\__init__.py", line 221, in
locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__
AttributeError: module 'pyscreeze' has no attribute 'locateOnWindow'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2021-08-28
@Realno_cheal

Apparently there is a version conflict between the libraries. Try to install these versions via pip (I just happened to have them at hand and worked successfully)

PyScreeze==0.1.26
PyAutoGUI==0.9.50

A
alexbprofit, 2021-08-28
@alexbprofit

from mss import mss

with mss() as sct:
    sct.shot()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question