Unable to get Kivy to work with Pycharm Community edition
I have installed Python 3.7.4 on windows 10 and installed Kivy via PIP . Kivy appears to be installed correctly as I can run the folloing code in a py file from the Python IDLE
import kivy
kivy.require('1.0.6') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
However either copying this code or dropping the file in pycharm and running I get an error "import kivy
ModuleNotFoundError: No module named 'kivy' "
I have python installed in C:\Users\username\AppData\Local\Programs\Python\Python37\python.exe
I've tried selecting Kivy as interpreter under "Add Python Interpreter" and pointing toward the Kivy directory which is in directory
C:\Users\gmoor\AppData\Local\Programs\Python\Python37\Lib\site-packages\kivy
However it does not allow me to select OK .
Not sure what I'm or have done wrong here. Help very much appreciated. Thank you
Please sign in to leave a comment.
Hi,
Most likely you are using two different interpreters. One of them has kivy installed and another one doesn't.
Please follow the tutorial to install kivy to your current Project Interpreter in PyCharm https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
Or use the same interpreter you use for Python IDLE.
Hi Sergey, thank you for your reply. In between my posting my query and you posting your reply, I manage to have it work if I have a project that is in the kivy_venv directory but no if the project is outside the kivy_venv directory even though I am now able to select the kivy interpreter "Python 3.7 (kivy_venv)" and save it in settings.
Gmoore, can you please expand on your explanation please. Should the project be in the kivy_venv directory?
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
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