我通过以下方式安装了 pySDL2 0.4.1:
下载源码包,输入python setup.py install
. 然后我尝试运行复制粘贴到 PyDev eclipse 中的“The Pong Game: Getting Started”教程代码示例:
导入操作系统、系统
try:
os.environ["PYSDL2_DLL_PATH"] = "/home/me/workspace/Pong/third-party"
print(os.getenv("PYSDL2_DLL_PATH"))
from sdl2 import events, SDL_QUIT
import sdl2.ext as 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()
for event in events:
if event.type == SDL_QUIT:
running = False
break
window.refresh()
return 0
if __name__ == "__main__":
sys.exit(run())
我收到以下错误:
Traceback (most recent call last):
File "/home/me/workspace/Pong/Main.py", line 11, in <module>
from sdl2 import *
File "/usr/local/lib/python3.3/dist-packages/sdl2/__init__.py", line 2, in <module>
from .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 any library for %s" % libinfo)
RuntimeError: could not find any library for SDL2
我通过 Synaptic 安装了 Pypy 和 libSDL,并且在 PyDev - PythonPath 中没有添加任何外部库。
我究竟做错了什么?