问题描述
所以我想我会玩转,尝试学习Kivy,因为它看起来很有趣.我刚刚开始尝试使他们的示例之一起作用:
So I thought I'd toy around and try and learn Kivy, as it looks interesting. I have just started trying to get one of their examples working:
from kivy.app import App
from kivy.uix.widget import Widget
class MyPaintWidget(Widget):
pass
class MyPaintApp(App):
def build(self):
return MyPaintWidget()
if __name__ == '__main__':
MyPaintApp().run()
我收到以下错误:
C:\Kivy-1.8.0-py2.7-win32>python paint.py
Traceback (most recent call last):
File "paint.py", line 1, in <module>
from kivy.app import App
ImportError: No module named kivy.app
我已经安装了最新版本的Kivy.我在C:\ Kivy-1.8.0-py2.7-win32 \ kivy \ kivy文件夹中看到app.py.
I have installed the latest version of Kivy. I see "app.py in the C:\Kivy-1.8.0-py2.7-win32\kivy\kivy folder.
另外,这是我的PYTHONPATH:
Also, here is my PYTHONPATH:
>>> import sys
>>> for n in sys.path:
... print n
...
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\site-packages\setuptools-2.0.1-py2.7.egg
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\site-packages\pywin32-218-py2.7-win32.egg
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\site-packages\plyer-1.1.2-py2.7.egg
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\site-packages\kivy_garden-0.1.1-py2.7.egg
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\site-packages\requests-2.2.1-py2.7.egg
C:\Kivy-1.8.0-py2.7-win32\Python27\python27.zip
C:\Kivy-1.8.0-py2.7-win32\Python27\DLLs
C:\Kivy-1.8.0-py2.7-win32\Python27\lib
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\plat-win
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\lib-tk
C:\Kivy-1.8.0-py2.7-win32\Python27
C:\Kivy-1.8.0-py2.7-win32\Python27\lib\site-packages
任何帮助将不胜感激.谢谢.
Any help would be greatly appreciated. Thank you.
推荐答案
我将脚本命名为kivy.py
时遇到了此错误消息,因为python首先在当前目录中查找该依赖项,因此它从未看到真实 kivy
软件包.
I ran into this error message when I named the script kivy.py
, because python looks first in the current directory to fill the dependency, so it never sees the real kivy
package.
重命名脚本已为我修复.
Renaming the script fixed it for me.
这篇关于没有名为kivy.app的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!