4

I have a problem with pysdl2. I'm trying to launch 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 which don't use sdl2_ttf (such as sdl2hello.py) work correctly and without errors. I have no idea how to solve it.

Additional info: WinXP SP3 32bit

Mark Hildreth
  • 42,023
  • 11
  • 120
  • 109
wiygn
  • 61
  • 3
  • 5

2 Answers2

4

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

Following the instructions of the PySDL2 manual, you must have set a PYSDL2_DLL_PATH like so:

# 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 have to get the SDL2_ttf package here: http://www.libsdl.org/projects/SDL_ttf/ and download the runtime library corresponding to your system (http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12-win32-x86.zip) and add it in the same folder where SDL2.dll is. Check out at C:\your-python-directory\DLLs

It's the same with SDL_image, SDL_mixer, SDL_net and SDL_gfx (on another website though for this last one).

Hope this helps !

Mark Hildreth
  • 42,023
  • 11
  • 120
  • 109
achedeuzot
  • 4,164
  • 4
  • 41
  • 56
1

Got the same issue

brew install sdl2

Solved my problem on OSX

Peko Chan
  • 306
  • 5
  • 15