我发布了回溯,其中说需要Pillow软件包,但它已与PyAutoGUI一起安装。我已经安装了以前的版本,希望可以解决该问题。还没有...
我正在32位Windows XP上进行制作(是的,我知道,它已经在5年前达到停产,但是目标计算机具有WinXP。
以下是我已安装的所有软件包的列表:
Package Version
----------- -------
MouseInfo 0.1.2
numpy 1.16.6
Pillow 6.0.0
pip 20.0.2
PyAutoGUI 0.9.48
PyGetWindow 0.0.8
PyMsgBox 1.0.7
pyperclip 1.7.0
PyRect 0.1.4
PyScreeze 0.1.26
PyTweening 1.0.3
setuptools 41.2.0
你们能帮我吗?
代码:
# Standard imports
import cv2
import numpy as np
import time
import pyautogui
import datetime
import time
global LatestLine
# Square 1 Coordinates - Check if machine is working
x1=280
y1=55
h1=31
w1=33
# Square 2 Coordinates - Check if program is active
x2=157
y2=177
h2=38
w2=38
while True:
#Get Screenshot
imagem = pyautogui.screenshot()
imagem.save(r'C:/Machine_Tracker/Imagem_Moving.png')
print ("Screenshot taken")
#Set image
imagem = cv2.imread("C:/Machine_Tracker/Imagem_Moving.png", cv2.IMREAD_GRAYSCALE)
im = cv2.bitwise_not(imagem)
now = datetime.datetime.now()
# Read square 1 - Check if machine is working
print "Crop image to check if machine is working"
crop_img = im[y1:y1+h1, x1:x1+w1]
n_white_pix1 = np.sum(crop_img == 255)
print('Number of white pixels:', n_white_pix1)
#cv2.imshow("Machine Status: White Pixels: {0}".format(n_white_pix1), crop_img)
cv2.imwrite("C:/Machine_Tracker/Machine_Status/MachineStatus.png", crop_img)
# Read square 2 - Check if program is active
print "Crop image to check if program is active"
crop_img = im[y2:y2+h2, x2:x2+w2]
n_white_pix2 = np.sum(crop_img == 255)
print('Number of white pixels:', n_white_pix2)
#cv2.imshow("Program Status: White Pixels: {0}".format(n_white_pix2), crop_img)
cv2.imwrite("C:/Machine_Tracker/App_Status/AppStatus.png", crop_img)
#Se Estiver na app
# Se Estiver a trabalhar
#Escreve "Working + DateTime"
# Else
#Escreve "Not Working + DateTime"
#EndIf
# Else
#Escreve "Fora Da App + Datetime"
#endif
if n_white_pix2 == 608: #Esta na app
if n_white_pix1 <= 1023: #Esta a trabalhar
#Quando a maquina nao esta a trabalhar,
#o bocado que vamos buscar tem 1023 pixeis brancos
#Sempre que e menor que esse valor, a maquina esta a trabalhar
#Write machine working log to file
Log = open("C:/Machine_Tracker/StatusLog.txt", "w")
LatestLine = "{0} - App is open and Machine is working\n".format(now.strftime("%Y-%m-%d %H:%M:%S"))
Log.write(LatestLine)
Log.close()
#print LatestLine
print(LatestLine)
else:
#Write machine working log to file
Log = open("C:/Machine_Tracker/StatusLog.txt", "w")
LatestLine = "{0} - App is open but Machine is NOT working\n".format(now.strftime("%Y-%m-%d %H:%M:%S"))
Log.write(LatestLine)
Log.close()
print(LatestLine)
else:
#Write machine working log to file
Log = open("C:/Machine_Tracker/StatusLog.txt", "w")
LatestLine = "{0} - App is NOT open\n".format(now.strftime("%Y-%m-%d %H:%M:%S"))
Log.write(LatestLine)
Log.close()
print(LatestLine)
time.sleep(20)
cv2.waitKey(0)
追踪:
Traceback (most recent call last):
File "C:\Python27\Check_for_Status.py", line 24, in <module>
imagem = pyautogui.screenshot()
File "C:\Python27\lib\site-packages\pyscreeze\__init__.py", line 134, in wrapper
raise PyScreezeException('The Pillow package is required to use this function.')
PyScreezeException: The Pillow package is required to use this function.
我目前正在制作一个需要截图并比较其中一些内容的应用。经过一段时间,目前,我设法获得了与以前不同的错误,在...