python 3.x - How can I get python3.4 to find the PySDL2 module I downloaded on win7? -
i downloaded pysdl2 (from https://bitbucket.org/marcusva/py-sdl2/downloads) , unzipped sdl2 package folder c:\python34\lib\site-packages\pysdl2-0.9.3, has subfolder sdl2 has subfolder ext.
i copied 'hello world' program same folder, using header:
import os os.environ["pysdl2_dll_path"] = "/python34/lib/site-packages/pysdl2-0.9.3" import sys import sdl2.ext
i ran same folder, , said couldn't find sdl2. (i used os.environ line, since had 'set' environment variable, didn't help)
importerror: not find library sdl2 (pysdl2_dll_path: /python34/lib /site-packages/pysdl2-0.9.3/sdl2)
so ran pip install pysdl2, , said: c:\python34\lib\site-packages\pysdl2-0.9.3>pip install pysdl2 requirement satisfied (use --upgrade upgrade): pysdl2 in c:\python34\ lib\site-packages cleaning up...
so, have package in python library, have pointed in environment, , pip says there, somehow python can't find import.
what should doing?
pysdl2 doesn't come sdl2 libraries.
you need sdl2 libraries pysdl2 work. sdl2 library hard work. pysdl2 interface allow access python.
have @ http://pysdl2.readthedocs.org/en/latest/install.html details how install it. , @ http://pysdl2.readthedocs.org/en/latest/integration.html information how use pysdl2_dll_path
for projects chose not install pysdl2 in python @ all. put pysdl2 stuff in project subdirectory called "sdl2", , windows sdl2 dlls in separate subdirectory called "sdl2_dll". in root directory of project have following file called sdlimport.py
"""imports pysdl2 module imports pysdl2 , sdl2 libraries held within project structure (i.e. not installed in python or in system). setup: [myproject] |-sdlimport.py |-main.py |-[sdl2] | |-the pysdl2 files |-[sdl2_dll] |-sdl2.dll |-sdl2_image.dll |-sdl2_mixer.dll |-sdl2_ttf.dll |-and other dlls needed edit sdlimport.py include bits of sdl2 need. example: sdlimport import * sdl2.dostuff() """ import os # app_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") app_dir = os.path.dirname(os.path.realpath(__file__)) """str: path project, detected @ import time """ sdl2_dll_path = os.path.join(app_dir, "sdl2_dll") os.environ["pysdl2_dll_path"] = sdl2_dll_path #--- comment these out needed --- import sdl2 import sdl2.sdlimage import sdl2.sdlttf #import sdl2.sdlgfx #import sdl2.sdlmixer import sdl2.ext
then, in each file needs pysdl2, use from sdlimport import *
Comments
Post a Comment