0

I'm following a youtube tutorial that gives an introduction to kivy and apps made in python.

I'm using pycharm and I'm meant to get a text box appear once my script has run. My script:

import kivy
from kivy.app import App
from kivy.uix.button import Label
import pillow
import image


class MyApp(App):

    def build(self):
        return Label(text='Hello Kivy')


if __name__ == '__main__':
    MyApp().run()

I've added import pillow / image because I found questions on SO that had the same issue I had so I've managed to sort that error and now encountered a new error which I have no idea what to do.

The SO questions:

1

2

3

My Error is:

Traceback (most recent call last):
   File "C:/Users/xxxx/PycharmProjects/MyProject/App test.py", line 4, in <module>
     import pillow
 ModuleNotFoundError: No module named 'pillow'

I've put import pillow at the top and also added the module in pycharm (file > settings > +) and on command prompt pip install pillow so why is "No module named 'pillow'" appearing?. So what do I have to do for this text box to appear? The youtube video can show what is meant to happen to be more clearer (skip to (9:50)). Thanks

Full Error:

C:\Users\xxxx\PycharmProjects\MyProject\venv\Scripts\python.exe "C:/Users/xxxx/PycharmProjects/MyProject/App test1.py"
[INFO   ] [Logger      ] Record log in C:\Users\xxxx\.kivy\logs\kivy_20-06-03_87.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "C:\Users\xxxx\PycharmProjects\MyProject\venv\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 11:52:54) [MSC v.1900 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\xxxx\PycharmProjects\MyProject\venv\Scripts\python.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: pil(['text_sdl2'] ignored)
[CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - ImportError: DLL load failed: The specified module could not be found.
  File "C:\Users\xxxx\PycharmProjects\MyProject\venv\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "C:\Users\xxxx\PycharmProjects\MyProject\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
    from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App         ] Unable to get a Window, abort.

4 Answers4

0

Write this on your terminal :

python -m pip install pillow

Or:

File/Settings/Project: [Your Project Name]/Project Interpreter/ + / Pillow

These solutions should work. If they don't you can always ask me on comments. Happy Coding!

Emir Sürmen
  • 884
  • 3
  • 14
  • 33
  • "Requirement already satisfied: Pillow in c:\users\xxxx\anaconda3\lib\site-packages (7.0.0) Note: you may need to restart the kernel to use updated packages." I'm super confused! – pragmatic learner Jun 03 '20 at 19:36
0

As far I can see in the tutorial you don't need to import pillow.

only these will do.

import kivy
from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):

    def build(self):
        return Label(text='Hello Kivy')


if __name__ == '__main__':
    MyApp().run()

try creating a virtual environment in pycharm and run the following commands in the venv.

pip install --upgrade pip wheel setuptools
pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
pip install kivy.deps.gstreamer
pip install kivy.deps.angle
pip install pygame
pip install kivy
Vignesh Krishnan
  • 743
  • 8
  • 15
0

What pillow version you got?

This should work:

from PIL import Image

reffering to other question (link), this can work on some version so PIL import Image

Grzegorz Krug
  • 186
  • 2
  • 11
0

Managed to figure it out after a few trials and errors after looking at and reading other programmers results that didn't work for me, I managed to find out why it didn't.

I had downloaded Pycharm AND Anaconda and therefore had TWO versions of python on my device. I uninstalled everything (wasn't a big deal) and then downloaded python 3.7.7 again - retried exact same code and it worked.

Installations:

pip install --upgrade pip wheel setuptools
pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
pip install kivy.deps.gstreamer
pip install kivy.deps.angle
pip install pygame
pip install kivy

all came up "already satisfied" because they were on ONE copy of python - not the one Pycharm was using. So if anyone else has this issue, check to see if you also have more than one version of python on your device as it will cause confusion. To make things easy instead of uninstalling everything (which I should've realized) you could also switch "my project interpreter" to see if that works.

Rookie mistake! - Thanks for the effort of helping to answer this question!