eclipse - RuntimeError for SDL2 after installing pySDL2 -
i installed pysdl2 0.4.1 by:
downloading source package, entering python setup.py install
. tried run copypasted pydev eclipse "the pong game: getting started" tutorial code example:
import os, sys
try: os.environ["pysdl2_dll_path"] = "/home/me/workspace/pong/third-party" print(os.getenv("pysdl2_dll_path")) sdl2 import events, sdl_quit import sdl2.ext sdl2ext except importerror: import traceback traceback.print_exc() sys.exit(1) def run(): sdl2ext.init() window = sdl2ext.window("the pong game", size=(800, 600)) window.show() running = true while running: events = sdl2ext.get_events() event in events: if event.type == sdl_quit: running = false break window.refresh() return 0 if __name__ == "__main__": sys.exit(run())
i got following error:
traceback (most recent call last): file "/home/me/workspace/pong/main.py", line 11, in <module> sdl2 import * file "/usr/local/lib/python3.3/dist-packages/sdl2/__init__.py", line 2, in <module> .dll import get_dll_file, _bind file "/usr/local/lib/python3.3/dist-packages/sdl2/dll.py", line 90, in <module> dll = _dll("sdl2", ["sdl2", "sdl2-2.0"], os.getenv("pysdl2_dll_path")) file "/usr/local/lib/python3.3/dist-packages/sdl2/dll.py", line 51, in __init__ raise runtimeerror("could not find library %s" % libinfo) runtimeerror: not find library sdl2
i have both pypy , libsdl installed via synaptic , have no external libraries added in pydev - pythonpath.
what doing wrong?
it seems pysdl2 doesn't find sdl2
runtime library. available on libsdl download page (except linux).
you should let pysdl2 library setting pysdl2_dll_path
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
or in python script:
# win32 platform path os.environ["pysdl2_dll_path"] = "c:\\path\\to\\fancy_project\\third_party" # unix/posix-alike environments path os.environ["pysdl2_dll_path"] = "/path/to/fancy_project/third_party"
that way, pysdl2 find library files (as long path correct of course) ! seems me easier way.
happy coding sdl2 !
Comments
Post a Comment