gpt4 book ai didi

macos - Virtualenv 中的 Kivy 对 SDL2 的支持

转载 作者:行者123 更新时间:2023-12-02 04:40:49 24 4
gpt4 key购买 nike

我按照以下步骤在 virtualenv (Mac OSX) 中安装 kivy,并支持 sdl2

$ brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer
$ pip install -I Cython
$ USE_OSX_FRAMEWORKS=0 pip install kivy

但是当尝试运行基本文档代码时

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput


class LoginScreen(GridLayout):

def __init__(self, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text='User Name'))
self.username = TextInput(multiline=False)
self.add_widget(self.username)
self.add_widget(Label(text='password'))
self.password = TextInput(password=True, multiline=False)
self.add_widget(self.password)


class MyApp(App):

def build(self):
return LoginScreen()


if __name__ == '__main__':
MyApp().run()

我收到以下错误

[INFO              ] [Logger      ] Record log in /Users/manthansharma/.kivy/logs/kivy_16-08-25_68.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v3.5.2 (default, Aug 16 2016, 05:35:40)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_imageio, img_dds, img_gif (img_pygame, img_pil, img_ffpyplayer ignored)
[CRITICAL ] [Text ] Unable to find any valuable Text provider at all!
pygame - ImportError: No module named 'pygame'
File "/Users/manthansharma/virtualenvs/kivy/lib/python3.5/site-packages/kivy/core/__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "/Users/manthansharma/virtualenvs/kivy/lib/python3.5/site-packages/kivy/core/text/text_pygame.py", line 12, in <module>
import pygame

pil - ImportError: No module named 'PIL'
File "/Users/manthansharma/virtualenvs/kivy/lib/python3.5/site-packages/kivy/core/__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "/Users/manthansharma/virtualenvs/kivy/lib/python3.5/site-packages/kivy/core/text/text_pil.py", line 8, in <module>
from PIL import Image, ImageFont, ImageDraw

[CRITICAL ] [App ] Unable to get a Text provider, abort.

我还尝试在 KIVY_SDL2_PATH 中给出 sdl2.dylib 的路径,但没有得到任何结果,但使用 kivy.app 工作正常,但我想使用 virtualenv

最佳答案

我在我的新 Mac (Sierra) 上也遇到了类似的错误。我遵循了https://github.com/kivy/kivy/issues/4688的建议

并使用命令安装最新版本的 Kivy
USE_OSX_FRAMEWORKS=0 pip install https://github.com/kivy/kivy/zipball/master

这对我有用,Kivy 现在使用 SDL2,而不是寻找 pygame。
以前,我要么需要 pygame,但在调整窗口大小时收到有关“Windows BMP 文件”的错误,或者如果我删除了 pygame,它找不到我用brew 安装的 SDL2。

关于macos - Virtualenv 中的 Kivy 对 SDL2 的支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39141563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com