我正在尝试在 Eclipse IDE 中使用适用于 python 的 Kivy 库。我尝试了一些在谷歌上找到的解决方案,但似乎都不起作用。我使用 Mac OSX 10.7 和 python 2.7。
我已经使用命令安装了 kivy setup.py 文件
python setup.py install
我现在如何在/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/中建立一个 kivy 文件夹。在 Eclipse 中,我转到 Preferences->PyDev->Interpreter,在可以添加库的位置,我添加该路径并应用更改。在编写 python 代码时,我现在可以从 kivy 导入我需要的所有内容,不会出现错误,并使用 kivy 模块编写具有代码补全功能的代码。当我尝试使用代码运行项目时,
import kivy
from kivy.app import App
from kivy.uix.widget import Widget
class PongGame(Widget):
pass
class PongApp(App):
def build(self):
return PongGame()
if __name__=='__main__':
PongApp().run()
我收到错误,
如何设置 Eclipse,这样我就不会收到此错误,并且可以直接从 Eclipse 运行 Kivy 程序?
最佳答案
在最近的Google Groups post中,Russell Owen 概述了他如何构建 PyGame 的 64 位版本1.9.1 适用于 Mac OS X 10.6 (Snow Leopard),并且还提供了指向 pre-built 64-bit PyGame OS X binary dmg 的 URL文件!
pygame-1.9.1release-py2.7-python.org-macosx10.6.dmg
拉塞尔的指示是:</p>
Building pygame 1.9.1 on Mac OS X 10.6 using XCode 3.2.6
2012-04-12
I was building this for a binary distribution that would run against python.org's 64-bit Python 2.7.2, for use on Mac OS X 10.6 and later.
* Install dependencies:
- libjpeg (use ./configure, make, sudo make install)
- SDL and extra packages (use precompiled framework builds):
- SDL
- SDL_mixer
- SDL_image
- SDL_ttf
- portmidi (use CMake as per the instructions)
* Delete shared libraries in /usr/local/lib (if you want to build a binary installer that can be used elsewhere).
* Check for /usr/local/lib/portmidi.a and if not found, make it a symlink from /usr/local/lib/portmidi_s.a or whatever portmidi got installed.
* Modify config_darwin.py to include '/usr/X11/include' and '/usr/X11/lib':
incdirs = ['/usr/X11/include', '/usr/local/include']
libdirs = ['/usr/X11/lib/', '/usr/local/lib']
(since libpng and libfreetype are standard in /usr/X11)
* Configure pygame and make sure it finds everything:
python config.py
As of 2012-04-12 on Mac OS X 10.6 I found that png was NOT found. I have no idea why, but I went ahead and installed it manually.
Also SCRAP is not found, but apparently that is normal for Mac OS X.
* Build pygame normally
python setup.py build
bdist_mpkg (or sudo python setup.py install if you don't want a binary installer)
希望这些说明适用于更新版本的 OS X 和 XCode(如果适用,请告知我们)。
谢谢
关于Mac 上 Eclipse IDE 中的 Python Kivy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13734341/