简体   繁体   English

使用Kivy和Python 3.4

[英]Using Kivy with Python 3.4

I have installed Kivy on my Mac. 我在Mac上安装了Kivy。 OS X comes installed with Python 2.7. OS X随Python 2.7一起安装。 I wanted to use the enum feature of Python 3, so I installed Python 3.4. 我想使用Python 3的枚举功能,所以我安装了Python 3.4。 After much searching and oulling of hair, I was pointed to this line 经过大量的搜索和头发,我被指向这条线

exec $(python -c "import os, sys; print os.path.normpath(sys.prefix)")/bin/python2.7 "$@"

in the file /Applications/Kivy.app/Contents/Resources/script. 在文件/Applications/Kivy.app/Contents/Resources/script中。 I changed it to: 我改成了:

exec /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 "$@"

in the hope of forcing Kivy to use Python 3.4. 希望强迫Kivy使用Python 3.4。

I now get this error: 我现在得到这个错误:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from kivy.app import App
  File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/app.py", line 321, in <module>
    from kivy.base import runTouchApp, stopTouchApp
  File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/base.py", line 29, in <module>
    from kivy.event import EventDispatcher
  File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/event.py", line 8, in <module>
    import kivy._event
ImportError: dlopen(/Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so, 2):    Symbol not found: _PyString_Type
  Referenced from: /Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so
  Expected in: flat namespace
 in /Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so

Can anyone help in fixing this error? 任何人都可以帮助修复此错误? Or is there a better way to get Kivy to use Python 3.4? 或者有更好的方法让Kivy使用Python 3.4吗?

I have installed Kivy 1.8.0. 我已经安装了Kivy 1.8.0。

I am running the app from the terminal, eg 我正在从终端运行应用程序,例如

kivy main.py

This line: 这一行:

dlopen(/Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so, 2)

Is trying to open a shared object, which would have been compiled for the explicit version of Python that your install of Kivy was intended for. 正在尝试打开一个共享对象,该对象本来是为您安装Kivy的Python的显式版本编译的。

Any Python package that includes precompiled dependencies will only work for the version of Python they were compiled against. 任何包含预编译依赖项的Python包只适用于编译它们的Python版本。

Kivy has not yet been tested with Python 3.4. Kivy尚未使用Python 3.4进行测试。 It runs fine with Python 3.3. 它在Python 3.3中运行良好。

I've gotten kivy working on OSX El Capitan with Python 3.5. 我已经开始使用Python 3.5在OSX El Capitan上工作了。 Here's how I did it. 这就是我做到的。

You will need to brew install the dependencies, then modify setup.py to use the brew installed dependencies. 您将需要brew安装依赖项,然后修改setup.py以使用brew安装的依赖项。 The default setup.py will look to your frameworks directory, but that's not where brew puts the new files! 默认的setup.py将查看您的frameworks目录,但这不是brew放置新文件的位置!

I was able to install kivy for python 3.5. 我能够为python 3.5安装kivy。 I didn't have to do anything extra, just regular install kivy and it is working. 我没有做任何额外的事情,只需定期安装kivy并且它正在工作。

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

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