如何在 Windows 上为 PyCharm 配置 Python Kivy? [英] How to configure Python Kivy for PyCharm on Windows?

查看:38
本文介绍了如何在 Windows 上为 PyCharm 配置 Python Kivy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让 Kivy 在 Windows 7 上使用 PyCharm.我已经设法通过 File > 添加了大部分外部库.设置 >Python 解释器 >路径选项卡.

I'm having trouble getting Kivy to work with PyCharm on Windows 7. I've managed to add most of the external libraries through File > Settings > Python interpreters > Paths Tab.

我使用的是 Kivy 版本的 Python.当我运行一个 Kivy 应用程序时,可以使用 [右键单击 >发送至 >kivy.bat] 方法,它给了我这个错误:

I'm using the Kivy version of Python. When I run a Kivy app that works fine with using the [right click > send to > kivy.bat] method in PyCharm, it gives me this error:

Failed modules
Python 2.7.3 (C:/Python27/python.exe) 
_imagingtk
dde
gtk._gtk
pangocairo
Generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available

我认为问题可能与 cython 有关,因为我的文件无法识别 Cython *.pxd 格式的 kivy.properties 文件.

I think that the problem might be something to do with cython, as my file fails to recognise the kivy.properties file, which is of the Cython *.pxd format.

推荐答案

这个 Kivy 的 Wiki 页面 使用各种流行的IDE's 设置Kivy 有更好的答案和详细的命令.下面复制了它,并添加了 Pycharm 3.4 的信息.

This Kivy's Wiki page Setting Up Kivy with various popular IDE's has a better answer and detail commands. It is copied below with added information for Pycharm 3.4.

转到解压后的 Kivy 文件夹,为kivy.bat"创建指向同一目录中的python.bat"的符号链接(mklink python.bat kivy.bat).

Go to your unzipped Kivy folder, create a symbol link for "kivy.bat" pointing to "python.bat" in the same directory (mklink python.bat kivy.bat).

在 PyCharm 中添加 2 个新的 Python 解释器.

Add 2 new Python interpreters in PyCharm.

  • Bootstrapper:从 Kivy 包文件夹中选择之前创建的python.bat".
  • Project Interpreter:从 Kivy 包文件夹的 Python 子目录中选择python.exe".

对于项目解释器,添加直接包含在 Kivy 包文件夹中的kivy"目录的路径.在 PyCharm 3.4 中,路径选项卡隐藏在子菜单中.在Project Interpreter中,点击interpreter下拉列表旁边的工具图标,点击more...(最后一个),在所有project interpreter列表中,选择Run-Configuration Interpreter,右侧有五个图标(+、-、编辑、虚拟环境和路径),单击路径在解压的 Kivy 文件夹中添加 Kivy 子目录.

For the project interpreter, add a path to the "kivy" directory directly contained in the Kivy package folder. In PyCharm 3.4, the path tab is hidden in a sub menu. In Project Interpreter, click the tool icon next to the interpreter dropdown list, click more... (the last one), in the list of all project interpreters, select Run-Configuration Interpreter, on the right side there are five icons (+, -, edit, virtual env, and path), click path to add the Kivy sub-directory in unzipped Kivy folder.

保存所有设置并忽略有关无效输出格式"的警告.确保项目解释器设置为我们之前创建的配置.

Save all settings and ignore warnings about "Invalid output format". Make sure that the project interpreter is set to our earlier created configuration.

创建一个新的运行配置并将 Python 解释器设置为我们之前创建的引导程序.

Create a new run configuration and set the Python interpreter to our earlier created bootstrapper.

只需运行配置即可执行您的 Kivy 应用程序

Simply run the configuration to execute your Kivy application

这篇关于如何在 Windows 上为 PyCharm 配置 Python Kivy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆