本文介绍了我可以从Pyscripter内运行Kivy程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Pyscripter中输入了这个代码:

  import kivy 

kivy.require( '1.7.2')

从kivy.app import App

来自kivy.uix.label import标签

class MyApp(App):

def build(self):
return Label(text ='Hello Kivy')

MyApp()。run()

然后按Run按钮(绿色三角形)。
我得到以下错误:

 导入错误:没有名为kivy 

我可以做些什么来使这项工作吗?



PS我知道我可以离开Pyscripter并使用kivy.bat,
,但我想使用Pyscripter中的调试功能。

解决方案

我认为这可能是因为kivy.bat真的设置并使用了安装了kivy的第二个python发行版。但是,pyscripter正在使用您正常的系统安装,该安装没有安装kivy模块。



您可以告诉pyscripter将kivy解释器与正确的环境设置。我不知道如何(我从未在Windows上尝试过),但是例如是类似的,但是关于pycharm而不是pyscripter。我已经粘贴了下面的答案,其中一些具体涉及到pycharm,但类似的东西可能适用于pyscripter。

您还可以尝试在现有的python安装中安装kivy。 kivy网站上有这样的说明:。我没有尝试过,可能会有一些棘手的一点。


I've entered this code in Pyscripter:

import kivy

kivy.require('1.7.2')

from kivy.app import App

from kivy.uix.label import Label

class MyApp(App):

      def build(self):
          return Label(text='Hello Kivy')

MyApp().run()

I then press the Run button (the green triangle).I get the following error:

Import error: No module named kivy

What can I do to make this work?

P.S. I know I can leave Pyscripter and use kivy.bat,but I would like to use the debugging capabilities within Pyscripter.

解决方案

I think this is probably because kivy.bat really sets up and uses a second python distribution that has kivy installed. However, pyscripter is using your normal system installation, which does not have the kivy module installed.

You can probably tell pyscripter to use the kivy interpreter with the right environment set up. I don't know how exactly (I haven't ever tried on windows), but for instance this previous question is similar but about pycharm rather than pyscripter. I have pasted the answer below, some of it relates specifically to pycharm but something similar will probably work for pyscripter.

You can also try to install kivy in your existing python installation. The kivy website has instructions for this here. I haven't tried this, and there may be some tricky bits.

这篇关于我可以从Pyscripter内运行Kivy程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-20 12:21