【问题标题】:Python Kivy in Eclipse IDE on MacMac 上 Eclipse IDE 中的 Python Kivy
【发布时间】:2012-11-23 22:25:47
【问题描述】:

我正在尝试在 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 程序?

【问题讨论】:

    标签: python eclipse frameworks ide kivy


    【解决方案1】:

    在最近的 Google Groups post 中,Russell Owen 概述了他如何为 Mac OS X 10.6 (Snow Leopard) 构建 64 位版本的 PyGame 1.9.1,并提供了一个指向 pre-built 64-bit PyGame OS X binary dmg 文件的 URL!

    pygame-1.9.1release-py2.7-python.org-macosx10.6.dmg

    Russell 的指示是:

    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(如果适用,请告知我们)。

    谢谢

    【讨论】:

      【解决方案2】:

      查看输出中的导入错误,您似乎需要安装 pygame 和 PIL。

      pygame 安装看起来很棘手,但有一个使用 homebrew 安装 pygame 的指南:

      https://bitbucket.org/pygame/pygame/issue/82/homebrew-on-leopard-fails-to-install#comment-627494

      如果您安装了 Xcode,理论上您应该能够执行“easy_install PIL”或“pip install PIL”(如果您正在使用分发)。

      【讨论】:

      • 该死。 pygame 不适用于 64 位 python。我必须安装 32 位 python,我不想这样做。我猜我不会使用 Kivy。
      • @JakeRunzer 继续看看我的post 中的信息,看起来 64 位 Mac PyGame 编译问题可能已经解决了 ;-) 。干杯。
      猜你喜欢
      • 2016-07-10
      • 2011-04-04
      • 2013-12-19
      • 2015-08-02
      • 2014-06-02
      • 2016-07-03
      • 2019-06-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多