簡體   English   中英

RuntimeError:找不到SDL2_ttf的任何庫

[英]RuntimeError: could not find any library for SDL2_ttf

我有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位

此錯誤似乎是腳本找不到SDL2_ttf包的結果。

按照PySDL2手冊的說明 ,您必須設置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 )並將其添加到SDL2.dll所在的同一文件夾中。 請訪問C:\\your-python-directory\\DLLs

它與SDL_imageSDL_mixerSDL_netSDL_gfx (在另一個網站上雖然最后一個)。

希望這可以幫助 !

得到了同樣的問題

brew install sdl2

解決了我在OSX上的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM