Python Kivy in Eclipse IDE on Mac

I am trying to use the Kivy library for python in the Eclipse IDE. I have tried some solutions that I have found on google but none of them seem to work. I am using Mac OSX 10.7 with python 2.7.

I have installed the kivy setup.py file with the command

python setup.py install

I now how a kivy folder in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/. In eclipse I go to Preferences->PyDev->Interpreter and where I can add libraires I add that path and apply the changes. When writing python code I can now import everything I need from kivy without error and write code with code completion using the kivy modules. When I try to run the project with the code,

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()

I get the error,

How can I setup eclipse so I do not get this error and I can run Kivy programs straight from eclipse?

In a recent Google Groups post , Russell Owen outlined how he built a 64-bit version of PyGame 1.9.1 for Mac OS X 10.6 (Snow Leopard), and also provides a URL to a pre-built 64-bit PyGame OS X binary dmg file!

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

Russell’s instructions were:

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)

Hopefully, these instructions will work on more recent versions of OS X and XCode (please let us know if they do).

Thanks

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Python Kivy in Eclipse IDE on Mac

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录