0

I am having some problems with guizero(I'm a beginner). Every time I try to resize an Image an error pops up.

I installed pip with cmd and everything seemed fine(Newest pip version, newest python version). Imports:

#Imports---------

from guizero import App, TextBox, Drawing, Combo, Slider, Text
from tkinter import*

Here is a sample of code with some context:

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,
    )

The following line causes an error:

photo.image(0, 0, path_correct, width=1000, height=600)

This error pops up:

------------------------------------------------------------
*** GUIZERO WARNING ***
Image resizing - cannot scale the image as PIL is not available.
------------------------------------------------------------

Edit: After removing one python installation (I had one from Microsoft Store and another one, which I downloaded from python.org. I removed the one from Microsoft Store), the problem remains. But when running pip install --upgrade Pillow in cmd, cmd now reports an error:

Der Befehl "pip" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

So it basically reports: 'The command "pip" is either being misspelled or could not be found '. I run the code by right-clicking on the file in Windows Explorer, selecting 'Edit with IDLE' and running it with F5, or by clicking on 'Run'.

It would be awesome if someone could help me.

Thanks in advance

rema
  • 11
  • 1
  • Please provide a sample of your code to explain what you tried that prompted this error. – Vincent Chalmel Oct 01 '21 at 13:20
  • Please provide enough code so others can better understand or reproduce the problem. – Community Oct 01 '21 at 13:20
  • @VincentChalmel Okay, I added some code. Is it fine like that? (Sorry, I'm new here) – rema Oct 04 '21 at 17:52
  • I suggest installing PIL. – Code-Apprentice Oct 04 '21 at 18:03
  • @Code-Apprentice Well, it is installed. When running that in cmd, this pops up: 'Requirement already satisfied: Pillow in c:\users\...\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (8.3.2)' That confused me. – rema Oct 04 '21 at 18:36
  • @rema Are you using a virtual env? Are you running the `pip install` command in the same venv as you use to execute the code? – Code-Apprentice Oct 04 '21 at 19:07
  • @Code-Apprentice No, I am just using a normal windows installation. I am running the command with Windows cmd, is that wrong? Sorry for being as inexperienced as I am. – rema Oct 04 '21 at 19:48
  • @rema Don't apologize. It sounds like you have two different python installations. How do you run the program? And how do you install PIL? Please [edit] your question to show these details. – Code-Apprentice Oct 05 '21 at 17:01
  • @Code-Apprentice Okay, I did. Thanks for helping. – rema Oct 05 '21 at 17:37
  • And how do you run your program? – Code-Apprentice Oct 05 '21 at 18:08
  • @Code-Apprentice Oh. I forgot about that. Just added it. – rema Oct 05 '21 at 19:43
  • In its current state, your question is the same as the one I linked above. Hopefully it will help you make some progress here. – Code-Apprentice Oct 05 '21 at 20:30
  • @Code-Apprentice Thank you so much! That was the problem, after some tweaking, it finally worked. cmd didn't work for me, but the UI worked. That really helped me. – rema Oct 05 '21 at 22:25

1 Answers1

1

The problem is likely that you do not have PIL installed.

pip install --upgrade Pillow
kinderhead
  • 36
  • 3
  • Thanks, that what I assumed as well. But when running that in cmd, this pops up: 'Requirement already satisfied: Pillow in c:\users\...\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (8.3.2)' That confused me. – rema Oct 04 '21 at 18:33
  • Are you using a different python installation or venv than the one Pillow is installed in? – kinderhead Oct 04 '21 at 19:00
  • I don't think so, but I am not absolutely sure. How can I check that? – rema Oct 04 '21 at 19:42