Python 运行时错误:找不到SDL2\u ttf的任何库
我对pysdl2有问题。我正在尝试从site packages\sdl2\examples启动示例,并看到以下错误:Python 运行时错误:找不到SDL2\u ttf的任何库,python,sdl,game-engine,python-3.3,pysdl2,Python,Sdl,Game Engine,Python 3.3,Pysdl2,我对pysdl2有问题。我正在尝试从site packages\sdl2\examples启动示例,并看到以下错误: 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:\Python3
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
c:\Python33\Lib\site packages\sdl2\examples>python draw.py
回溯(最近一次呼叫最后一次):
文件“draw.py”,第10行,在
将sdl2.ext作为sdl2ext导入
文件“C:\Python33\lib\site packages\sdl2\ext\\uuuu init\uuuuu.py”,第14行,在
来自。普通进口*
文件“C:\Python33\lib\site packages\sdl2\ext\common.py”,第8行,在
从…起导入sdlttf
文件“C:\Python33\lib\site packages\sdl2\sdlttf.py”,第40行,在
getenv(“PYSDL2\u DLL\u路径”))
文件“C:\Python33\lib\site packages\sdl2\dll.py”,第51行,在\uuu init中__
raise RUNTIMERROR(“找不到%s”%libinfo)的任何库)
运行时错误:找不到SDL2\u ttf的任何库
但不使用sdl2_ttf的文件(如sdl2hello.py)工作正常且没有错误。我不知道怎么解决它
其他信息:WinXP SP3 32位此错误似乎是由于脚本未找到
SDL2\u ttf
包造成的
下面,您必须设置一个PYSDL2\u DLL\u路径
,如下所示:
# 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
因此,您只需在此处获取SDL2\u ttf
包:下载与您的系统()对应的运行库,并将其添加到SDL2.dll
所在的同一文件夹中。请在C:\your python directory\DLLs
这与SDL_image
、SDL_mixer
、SDL_net
和SDL_gfx
(在另一个网站上,尽管是最后一个网站)
希望这有帮助 也有同样的问题
brew install sdl2
解决了我在OSX上的问题