Using Kivy with Python 3.4

我的梦境 提交于 2019-12-10 07:58:34

问题


I have installed Kivy on my Mac. OS X comes installed with Python 2.7. I wanted to use the enum feature of Python 3, so I installed 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. 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.

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?

I have installed Kivy 1.8.0.

I am running the app from the terminal, e.g.

kivy main.py

回答1:


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.

Any Python package that includes precompiled dependencies will only work for the version of Python they were compiled against.




回答2:


Kivy has not yet been tested with Python 3.4. It runs fine with Python 3.3.




回答3:


I've gotten kivy working on OSX El Capitan with Python 3.5. Here's how I did it.

You will need to brew install the dependencies, then modify setup.py to use the brew installed dependencies. The default setup.py will look to your frameworks directory, but that's not where brew puts the new files!




回答4:


I was able to install kivy for python 3.5. I didn't have to do anything extra, just regular install kivy and it is working.



来源:https://stackoverflow.com/questions/22929345/using-kivy-with-python-3-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!