我是 Ubuntu 和 Python 的新手。基本上我按照网站告诉我的那样安装了 kivy。首先我构建了 repo
$ sudo add-apt-repository ppa:kivy-team/kivy
然后我做 apt
sudo apt-get install python3-kivy
好的,现在我启动 Geany 并按照网站说明执行臭名昭著的“Hello World”,然后当我在程序目录 ~/Documents/Kivy 中为我运行时
python helloWorld
这是应用程序的代码
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()
我立即得到错误
File "~/Documents/Kivy/helloWorld", line 1, in <module>
import kivy
知道为什么会这样吗?
最佳答案
你说apt install是:
sudo apt-get install python3-kivy
这将为 python3 安装 kivy... 而不是 python 2
而不是运行:
python helloWorld
尝试输入:
python3 helloWorld
关于python - 导入错误 : No module named kivy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31018610/