I am new to Ubuntu and Python. Basically I installed kivy just as the website told me to do.First I built the repo
$ sudo add-apt-repository ppa:kivy-team/kivy
Then I do the apt
sudo apt-get install python3-kivy
Ok now I fire up Geany and follow the websites instructions to do the infamous "Hello World" then when I run in the program directory ~/Documents/Kivy for me
python helloWorld
Here is the code for the app
import kivy
kivy.require('1.9.0')
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()
I immediately get the error
File "~/Documents/Kivy/helloWorld", line 1, in <module>
import kivy
Any clue why this is happening?
You said that the apt install is:
sudo apt-get install python3-kivy
That will install kivy for python3... not python 2
Instead of running:
python helloWorld
Try typing:
python3 helloWorld
For any noobs like myself looking to get this going on MAC OSX and totally confused, this is from the Kivy site:
"You can run any Kivy application by simply dragging the application's main file onto the Kivy.app icon."
After adding the ppa, you should do "sudo apt-get update" to make sure that the package is installed.
Also it is important you run it with "python3" instead of "python" which is generally the older version. kivy you downloaded is a python3 version and doesn't get imported by legacy 2.7 python.
I got it running with
python3 helloworld.py
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.