No Module Named 'kivy' Even Though I Installed It
Solution 1:
Check if in current enviroment you have kivy installed:
import pip._internal as pip
print([i.key for i in pip.get_installed_distributions()]
# or
pip.main(['freeze'])
So you will see if in this enviroment you have kivy installed. To make sure you have kivy installed in this enviroment you can write something like this:
try:
from kivy.app import App
except ImportError:
import pip._internal as pip
pip.main(['install', 'kivy'])
from kivy.app import App
Solution 2:
I was facing the same issue. After trying it multiple times, I came across this solution and it worked.
Basically, you need to create an interpreter which points to kivy folder('kivy_venv' folder which was created using steps similar to this installation link: https://kivy.org/doc/stable/installation/installation-windows.html#start-a-kivy-application
- Open Pycharm
- Click 'File' tab in upper left corner
- click on 'Settings'
- click on 'Project:test'
- click 'Python Interpreter'
- click on 'Settings symbol' (wheel shaped) next to 'Python Interpreter'
- click on 'show all'
- click on '+' plus symbol
- Set 'Location' to the folder where 'PycharmProject' folder is situated.(To find out PycharmProject folder location, click on File->Open->ProjectName ) (I would recommend you to create a new folder in PycharmProject say 'kivyProject1') In my case, Location is C:\Users\Shraddha\PycharmProjects\kivyProject1
- Set 'Interpreter' to the folder where kivy was installed.(If you installed kivy using steps at https://kivy.org/doc/stable/installation/installation-windows.html#start-a-kivy-application , you will have 'kivy_venv' folder. Copy the complete address of 'kivy_venv\Scripts\python.exe' and paste at 'Interpreter' ) In my case, Interpreter is C:\Users\Shraddha\AppData\Local\Programs\Python\Python37\kivy_venv\Scripts\python.exe
- Click on 'Edit' (a pencil shaped symbol at right side) and set name Name: Python 3.7 (kivyenv1) Keep Location as it was.In my case Location is C:\Users\Shraddha\PycharmProjects\kivyProject1\Scripts\python.exe
- Click OK. Then OK. Now you are out of 'Settings'.
- Create new python program filename.py to check if kivy is imported. For that, Click File->Create new project and ensure its location is C:\Users\Shraddha\PycharmProjects\kivyProject1\filename.py
- In filename.py, type import kivy and run by clicking on PLAY button. You must get logs as : succesfully imported kivy
Solution 3:
I had the same error. Am using windows 10 in VS code and below is a solution that works:
The solution was to run this:
python -m pip install kivy==2.0.0rc1
I don't know why this works, but the website instruction appears to use an older version:
python -m pip install kivy==1.11.1
which fails.
You can test by running a kivyTest.py
file with one line of code (below):
import kivy
Solution 4:
Short answer:
1) Open an Anaconda command prompt.
2) Type code
, and then press enter.
3) Now open your file and run your code in "this" VScode.
More explanation:
I was facing the same problem (installed kivy by running conda install kivy -c conda-forge
in an Anaconda command prompt), and I couldn't import kivy
in VScode that is opened normally and not from the Anaconda environment (got the ImportError: No module named 'kivy'
error), but then I opened VScode from Anaconda Navigator, and run the same code and this time I didn't get any error. Then I searched if it was possible to open VScode from Anaconda command prompt (like when you want to open an IPython notebook with jupyer notebook
), because the prompt loads much faster than the navigator. And found out it is done by typing code
and pressing enter.
Hope this helps you!
Solution 5:
if you installed it just restart your computer. I faced same problem I search on many sites I don't get solution than shutdown pc next day I restart it its working.
Post a Comment for "No Module Named 'kivy' Even Though I Installed It"