简体   繁体   English

Mac上的Eclipse IDE中的Python Kivy

[英]Python Kivy in Eclipse IDE on Mac

I am trying to use the Kivy library for python in the Eclipse IDE. 我正在尝试在Eclipse IDE中将Kivy库用于python。 I have tried some solutions that I have found on google but none of them seem to work. 我尝试了一些在google上找到的解决方案,但似乎都没有用。 I am using Mac OSX 10.7 with python 2.7. 我正在将Mac OSX 10.7与python 2.7一起使用。

I have installed the kivy setup.py file with the command 我已经使用命令安装了kivy setup.py文件

python setup.py install

I now how a kivy folder in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/. 我现在在/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/中如何找到kivy文件夹。 In eclipse I go to Preferences->PyDev->Interpreter and where I can add libraires I add that path and apply the changes. 在eclipse中,我转到Preferences-> PyDev-> Interpreter,然后在其中添加libraires的位置添加该路径并应用更改。 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. 现在,当编写python代码时,我可以无错误地从kivy导入我需要的所有内容,并使用kivy模块编写代码完成的代码。 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, 我得到错误, 猕猴桃python错误

How can I setup eclipse so I do not get this error and I can run Kivy programs straight from eclipse? 如何设置eclipse,这样我就不会出现此错误,并且可以直接从Eclipse运行Kivy程序?

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! 在最近的Google Groups帖子中 ,拉塞尔·欧文(Russell Owen)概述了他如何为Mac OS X 10.6(Snow Leopard)构建64位版本的PyGame 1.9.1,还提供了指向预先构建的64位PyGame OS X二进制文件的URL。 dmg文件!

pygame-1.9.1release-py2.7-python.org-macosx10.6.dmg pygame-1.9.1版本-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). 希望这些说明可以在OS X和XCode的最新版本上使用(请告知我们是否可以)。

Thanks 谢谢

Looking at the import errors in your output it would appear you need to install pygame and PIL. 查看输出中的导入错误,您似乎需要安装pygame和PIL。

The pygame install looks tricky but there's a guide for installing pygame with homebrew: pygame安装看起来很棘手,但是有一个使用自制软件安装pygame的指南:

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

If you have Xcode installed you should in theory be able to do 'easy_install PIL' or 'pip install PIL' if you're using distribute. 如果您安装了Xcode,则在理论上应该可以执行“ easy_install PIL”或“ pip install PIL”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM