简体   繁体   中英

Using Kivy with Python 3.4

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, 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.

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

Kivy has not yet been tested with Python 3.4. It runs fine with Python 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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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