I'm using Visual Studio Code for Python and I'm pretty sure that I installed required libraries from command prompt and also from Visual Studio Code's terminal. Normally all other libraries are working except for Kivy. I don't understand why. Here is the imports that not working when I tried to import:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
and here is the error:
ModuleNotFoundError: No module named 'kivy'
and here is the files that I installed with pip:
According to the information you provided, I have reproduced the issue you mentioned.
Then, I did the following steps:
I tried to use pip to install 'kivy', but it didn't work. Of course, it wasn't in the pip list.
I tried to install 'kivy' with conda and then the installation was successful, but it only appears in the conda list, not in the pip list.
conda install kivy -c conda-forge
I use the above installation command again. After the installation is completed, 'kivy' appears in the conda list and pip list.
Under 'from kivy.app import App
', the wavy line still exists. After I reload the VSCode window, all problems disappear.
As a test, I used the following code and ran the results successfully:
from kivy.app import App from kivy.lang import Builder from kivy.uix.screenmanager import Screen, ScreenManager from kivy.uix.button import Button class TestApp(App): def build(self): return Button(text = "hello") TestApp().run()
VSCode opens a Test file with content 'hello'.
My environment: python:3.7.7; VSCode:1.47.2 (with conda environment); Win10.
I don't know what conda is but I guess it is related to Anaconda. Whatever I install kivy also with
conda install kivy -c conda-forge
but nothing changed. Probably I must change the environment but I don't know how. Can you explain also this? And I tried also PyCharm, the error code is diffirent.File "C:\Python38\Lib\site-packages\kivy\clock.py", line 466, in <module> from kivy._clock import CyClockBase, ClockEvent, FreeClockEvent, \ ModuleNotFoundError: No module named 'kivy._clock'
@Nurqm This is an environment that uses Anaconda's own python interpreter in VSCode. You could refer to it to create this environment in VSCode:code.visualstudio.com/docs/python/…