Kivy、Eclipse 和 PyDev(也是 PyPy)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9768489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:50:52  来源:igfitidea点击:

Kivy, Eclipse and PyDev (also PyPy)

eclipsepydevpypykivy

提问by GaiusSensei

According to this post: https://groups.google.com/forum/?fromgroups#!topic/kivy-users/n7c3thksnzg, it is possible to use Eclipse as an IDE for Kivy through PyDev. However, I didn't understand the instructions. Can anyone please elaborate on how to connect Kivy with Eclipse.

根据这篇文章:https: //groups.google.com/forum/?fromgroups#! topic/kivy-users/n7c3thksnzg ,可以通过 PyDev 将 Eclipse 用作 Kivy 的 IDE。但是,我不明白说明。任何人都可以详细说明如何将 Kivy 与 Eclipse 连接起来。

Note: I'm on a Windows machine. Also, is it possible to use PyPy instead of the Python Interpreter?

注意:我在 Windows 机器上。另外,是否可以使用 PyPy 而不是 Python 解释器?

Thanks~!

谢谢~!

回答by Rabih Kodeih

Using Kivy with Pydev on Windows xp/7

在 Windows xp/7 上使用 Kivy 和 Pydev

  • Under Window/Preferences/PyDev/Interpreter-Python add a new interpreter pointing to the python executable which ships with kivy portable
  • add kivy package folder under libraries tab (still in Python Interpreters Prefs section making sure the kivy python interpreter is selected)
  • In Environment tab, add the following three key-value pairs: (assumptions: kivy root is c:\kivy)

    GST_REGISTRY = c:\kivy\gstreamer\registry.bin

    GST_PLUGIN_PATH = c:\kivy\gstreamer\lib\gstreamer-0.10

    PATH = c:\kivy;c:\kivy\Python;c:\kivy\gstreamer\bin;c:\kivy\MinGW\bin;%PATH%

  • When creating a new project intended to use kivy, just specify the appropriate interpreter and you should be ready to go

  • 在 Window/Preferences/PyDev/Interpreter-Python 下添加一个新的解释器,指向 python 可执行文件,它与 kivy 便携式
  • 在库选项卡下添加 kivy 包文件夹(仍然在 Python Interpreters Prefs 部分,确保选择了 kivy python 解释器)
  • 在 Environment 选项卡中,添加以下三个键值对:(假设:kivy root 是 c:\kivy)

    GST_REGISTRY = c:\kivy\gstreamer\registry.bin

    GST_PLUGIN_PATH = c:\kivy\gstreamer\lib\gstreamer-0.10

    路径 = c:\kivy;c:\kivy\Python;c:\kivy\gstreamer\bin;c:\kivy\MinGW\bin;%PATH%

  • 创建打算使用 kivy 的新项目时,只需指定适当的解释器,您就可以开始使用了

回答by Fabio Zadrozny

I think it's just pointing that:

我认为它只是指出:

回答by mojoken

After following instructions above I was still having problems with imports not found. I found I had to open my project's properties in Eclipse and under "PyDev - PYTHONPATH" add my kivy directory, e.g. C:\Kivy141\kivy

按照上述说明操作后,我仍然遇到找不到导入的问题。我发现我必须在 Eclipse 中打开我的项目属性,并在“PyDev - PYTHONPATH”下添加我的 kivy 目录,例如 C:\Kivy141\kivy

回答by Thanatocratos

As of kivy 1.9.0, PATH must also include c:\kivy\SDL2\bin or else when trying to run kivy will throw an error and fail at opening a window. I Think I read that kivy no longer use PyGame and shifted to SDL2 since the answer posted in april 2012.

从 kivy 1.9.0 开始,PATH 还必须包含 c:\kivy\SDL2\bin 否则在尝试运行 kivy 时会抛出错误并无法打开窗口。我想我读到自 2012 年 4 月发布的答案以来,kivy 不再使用 PyGame 并转向 SDL2。

回答by Lucian

I am using Windows 7 x64 with Eclipse Mars(release 4.5.1). The steps that worked for me(very close to Rabih answer):
1.I copied Kivy 1.9.0 on my local machine from here
2.I renamed the kivy.bat file to python.bat(this step can be ignored)
3.Eclipse->Window->Preferences->PyDev->Interpreters->Python Interpreter->New
and added the python.bat file as interpreter. After doing this the interpreter should look like in the image:enter image description here
4.In the Environement tab add the 3 keys everybody mentioned:
GST_REGISTRY = c:\kivy\gstreamer\registry.bin
GST_PLUGIN_PATH = c:\kivy\gstreamer\lib\gstreamer-0.10
PATH = c:\kivy;c:\kivy\Python;c:\kivy\gstreamer\bin;c:\kivy\MinGW\bin;%PATH%
5.Use the interpreter that you just created in your project. Note that a default one will be selected if you don't specify the one you created

我将 Windows 7 x64 与 Eclipse Mars(版本 4.5.1)一起使用。对我有用的步骤(非常接近 Rabih 的答案):
1.我从这里复制了本地机器上的 Kivy 1.9.0
2.我将 kivy.bat 文件重命名为 python.bat(这一步可以忽略)
3.Eclipse->Window->Preferences->PyDev->Interpreters->Python Interpreter->New
并添加了 python.bat 文件作为解释器。执行此操作后,解释器应如下图所示:4.在环境选项卡中添加每个人提到的 3 个键: GST_REGISTRY = c:\kivy\gstreamer\registry.bin GST_PLUGIN_PATH = c:\kivy\gstreamer\lib\gstreamer- 0.10 路径 = c:\kivy;c:\kivy\Python;c:\kivy\gstreamer\bin;c:\kivy\MinGW\bin;%PATH%在此处输入图片说明




5.使用您刚刚在项目中创建的解释器。请注意,如果您不指定您创建的那个,则会选择一个默认的

回答by karelok

Using Eclipse IDE with Kivy and Pydev on OS X

在 OS X 上使用带有 Kivy 和 Pydev 的 Eclipse IDE

  • Type which ivyin the terminal and locate the executable (it should be /usr/local/bin/kivy)
  • Then choose Preferences from Eclipse menu and navigate to PyDev -> Interpreters -> Python Interpreter.
  • Open the Select Interpreter dialog by clicking on the New... button (1) on the right.
  • Fill the name of interpreter (kivy) in the Interpreter Name field (2)
  • Fill the identified path (/usr/local/bin/kivy) in the Interpreter Executable field
  • Press OK and wait till the process will be done.
  • Do not forget to change interpreter settings in your project. You can do it by right click on your project in the Package Explorer under the PyDev - Interpreter/Grammar page.
  • 键入which ivy在终端和定位可执行文件(它应该是/ usr / local / bin中/ kivy)
  • 然后从 Eclipse 菜单中选择 Preferences 并导航到 PyDev -> Interpreters -> Python Interpreter。
  • 单击右侧的 New... 按钮 (1),打开 Select Interpreter 对话框。
  • 在 Interpreter Name 字段中填写解释器的名称 (kivy) (2)
  • 在 Interpreter Executable 字段中填写确定的路径 (/usr/local/bin/kivy)
  • 按确定并等待该过程完成。
  • 不要忘记更改项目中的解释器设置。您可以通过在 PyDev - Interpreter/Grammar 页面下的 Package Explorer 中右键单击您的项目来完成此操作。

enter image description here

在此处输入图片说明