RuntimeError:找不到SDL2_ttf的任何库

时间:2013-08-15 09:55:07

标签: python sdl game-engine python-3.3 pysdl2

我遇到了pysdl2的问题。我正在尝试从site-packages \ sdl2 \ examples启动示例,并看到此错误:

c:\Python33\Lib\site-packages\sdl2\examples>python draw.py
Traceback (most recent call last):
  File "draw.py", line 10, in <module>
    import sdl2.ext as sdl2ext
  File "C:\Python33\lib\site-packages\sdl2\ext\__init__.py", line 14, in <module>
        from .common import *
  File "C:\Python33\lib\site-packages\sdl2\ext\common.py", line 8, in <module>
    from .. import sdlttf
  File "C:\Python33\lib\site-packages\sdl2\sdlttf.py", line 40, in <module>
    os.getenv("PYSDL2_DLL_PATH"))
  File "C:\Python33\lib\site-packages\sdl2\dll.py", line 51, in __init__
    raise RuntimeError("could not find any library for %s" % libinfo)
RuntimeError: could not find any library for SDL2_ttf

但是不使用sdl2_ttf的文件(例如sdl2hello.py)可以正常运行且没有错误。我不知道如何解决它。

其他信息:WinXP SP3 32位

2 个答案:

答案 0 :(得分:4)

此错误似乎是脚本未找到SDL2_ttf包的结果。

关注the instructions of the PySDL2 manual,您必须设置PYSDL2_DLL_PATH,如此:

# Win32 platforms
set PYSDL2_DLL_PATH=C:\path\to\fancy_project\third_party

# Unix/Posix-alike environments - bourne shells
export PYSDL2_DLL_PATH=/path/to/fancy_project/third_party

# Unix/Posix-alike environments - C shells
setenv PYSDL2_DLL_PATH /path/to/fancy_project/third_party

所以你只需要在这里获取SDL2_ttf包:http://www.libsdl.org/projects/SDL_ttf/并下载与你的系统相对应的运行时库(http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12-win32-x86.zip)并将其添加到{{1}的同一文件夹中是的。查看SDL2.dll

C:\your-python-directory\DLLsSDL_imageSDL_mixerSDL_net相同(在另一个网站上虽然是最后一个)。

希望这有帮助!

答案 1 :(得分:0)

遇到同样的问题

brew install sdl2

解决了我在OSX上的问题