chribonn
chribonn

Reputation: 457

Kivy Installation Guide for Windows 10

I've been trying to follow online youTube videos to install kivy on my Windows 10 computer (python-3.7.5-amd64, kivy 1.11.1). Aside from the fact that they seem to have different variations on how they approach the topic, I am unable to get a solution that operates satisfactorily.

These are the steps I am following:

If I open a command prompt and attempt to execute the source code using the command python label.py I get the following:

Traceback (most recent call last):
  File "label.py", line 1, in <module>
    from kivy.app import App
  File "C:\Users\chrib\Google Drive\_Software\Python_Kivy\kivy.py", line 1, in <module>
    from kivy.base import runTouchApp
ModuleNotFoundError: No module named 'kivy.base'; 'kivy' is not a package

Why should this happen?

Also is it possible to have a cleaner development environment. I am used to Visual Studio IDE and it would be great if I can use this environment.

Thanks

Code for label.py

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();

Upvotes: 2

Views: 1038

Answers (2)

chribonn
chribonn

Reputation: 457

I figured it out. I had a program in the code directory called kivy.py. I renamed that and it worked.

Upvotes: 0

inclement
inclement

Reputation: 29488

I've been trying to follow online youTube videos to install kivy on my Windows 10 computer

Have you tried simply following the instructions on kivy.org? There's no need to use youtube videos, the installation is largely a normal python module install.

I try to run a simple program. From within Windows Explorer I right click the code file (label.py) and from the shortcut menu select python.

Don't do this, run the file by opening a command prompt and typing python yourfilename.py. That way you will see the full traceback for any errors that occur.

A windows pops up for an instant and a directory called pycache gets created with kivy.cpython-37.pyc. Double clicking that causes the program to run.

It sounds likely that the first run is crashing. As above, you want to get the information about why.

Is it possible to have a easier solution in which the source code, once compiled executes?

When you run the code it does execute. As above, it's probably crashing.

ModuleNotFoundError: No module named 'kivy.base'; 'kivy' is not a package

Have you made a file named kivy.py? It looks likely that you have, and that this file is being imported in preference to the installed kivy module.

Also is it possible to have a cleaner development environment. I am used to Visual Studio IDE and it would be great if I can use this environment.

I'm not sure what you consider unclean about your development environment, but you should think in terms of python environments and their installed packages. Kivy is just a python module that you install into a python environment. When you use an IDE, it may integrate with one or more python environments (with options to switch between them). There's nothing special about using Visual Studio with Kivy, just do whatever you normally do to use it with Python.

Upvotes: 2

Related Questions