RuntimeError: could not find library for SDL2_ttf

I have a problem with pysdl2. I am trying to run examples from site-packages \ sdl2 \ examples and see this error:

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 

But files that do not use sdl2_ttf (for example, sdl2hello.py) work correctly and without errors. I do not know how to solve it.

Additional Information: WinXP SP3 32bit

+4
source share
1 answer

This error seems to be the result of the script not finding the SDL2_ttf package.

Following the instructions in the PySDL2 manual , you should set PYSDL2_DLL_PATH like this:

 # 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 

so you just need to get the SDL2_ttf package here: http://www.libsdl.org/projects/SDL_ttf/ and download the runtime library appropriate for your system ( http://www.libsdl.org/projects/SDL_ttf/release/ SDL2_ttf-2.0.12-win32-x86.zip ) and add it to the same folder where SDL2.dll is located. Check out C:\your-python-directory\DLLs

Same thing with SDL_image , SDL_mixer , SDL_net and SDL_gfx (on another site, although for the latter).

Hope this helps!

+4
source

Source: https://habr.com/ru/post/1497204/


All Articles