我在使用 guizero 时遇到了一些问题(我是初学者)。每次我尝试调整图像大小时,都会弹出一个错误。
我用 cmd 安装了 pip,一切似乎都很好(最新的 pip 版本,最新的 python 版本)。进口:
#Imports---------
from guizero import App, TextBox, Drawing, Combo, Slider, Text
from tkinter import*
这是带有一些上下文的代码示例:
def draw_photo():
photo.clear()
print('path.value:', path.value, end='\n\n')
if path.value[0:1] == '\'' or path.value[0:1] == '\"':
path_better = path.value[1:]
else:
path_better = path.value
print('path_better:', path_better, end='\n\n')
if path_better[len(path_better)-1:] == '\'' or path_better[len(path_better)-1:] == '\"':
path_correct = path_better[:len(path_better)-1]
else:
path_correct = path_better
print('path_correct:', path_correct, end='\n\n')
photo.image(0, 0, path_correct, width=1000, height=600)
photo.text(
20, 20, top_text.value,
color=top_color.value,
size=top_size.value,
font=top_font.value,
)
photo.text(
20, 320, bottom_text.value,
color=bottom_color.value,
size=bottom_size.value,
font=bottom_font.value,
)
以下行导致错误:
photo.image(0, 0, path_correct, width=1000, height=600)
弹出此错误:
------------------------------------------------------------
*** GUIZERO WARNING ***
Image resizing - cannot scale the image as PIL is not available.
------------------------------------------------------------
编辑:删除一个 python 安装后(我从 Microsoft Store 安装了一个,从python.org下载了另一个。我从 Microsoft Store 删除了一个),问题仍然存在。但是pip install --upgrade Pillow
在cmd中运行时,cmd现在报错:
Der Befehl "pip" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
所以它基本上报告:'命令“pip”拼写错误或找不到'。我通过右键单击 Windows 资源管理器中的文件,选择“使用 IDLE 编辑”并使用 F5 运行它,或者单击“运行”来运行代码。
如果有人可以帮助我,那就太棒了。
提前致谢