Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python with PySDL2 - could not find any library for SDL2

I'm starting to use PySDL2 with Python 3.4 to make a game. Every time I run the "hello world" code given by the PySDL2 documentation it looks like I haven't installed the SDL library:

ImportError: could not find any library for SDL2 (PYSDL2_DLL_PATH: unset)

I have already tried to make a batch file to set the environment var:

set PYTHONPATH=C:\path\to\pysdl2\:$PYTHONPATH

and also tried to set the environment var through IDLE:

os.environ["PYSDL2_DLL_PATH"] = "path"

AND I've tried to even put the SDL.dll file in the System32 folder (btw I'm in a Windows x64 machine) I need help, so if you can't answer because there's not enough information just tell me

like image 336
BusaniX Avatar asked Sep 14 '14 15:09

BusaniX


2 Answers

SDL.dll does not sound like the correct DLL. Did you really download SDL2, not SDL? If so, you can put SDL2.dll into a directory of your choice and let your environment point to it:

os.environ["PYSDL2_DLL_PATH"] = "c:\\directory\of\\sdl2\\library"

This has to be done before any import sdl2... statement occurs.

Or you put the DLL file into the System32 folder.

You also should make sure that your Python installation matches the SDL2 build. If you use a 32-bit SDL2.dll, Python also must be a 32-bit build. If you use a 64-bit SDL2.dll, Python also must be a 64-bit build.

http://pysdl2.readthedocs.org/en/latest/faq.html and http://pysdl2.readthedocs.org/en/latest/install.html contain some more pointers.

like image 186
Marcus Avatar answered Sep 19 '22 13:09

Marcus


Actually what you need to do, is to have dll, so just pip install it

pip install pysdl2-dll
like image 21
Jan Avatar answered Sep 22 '22 13:09

Jan