Pygame:ImportError:libSDL_ttf-2.0.so.0:无法打开共享对象文件:没有这样的文件或目录

nav*_*vro 2 python linux pygame sdl cx-freeze

游戏从源代码运行良好.当我使用cx_Freeze在Linux上编译二进制文件时,我在第二台机器上遇到错误:

~/tmp/exe.linux-x86_64-2.7 $ ./rungame
/home/local/tmp/exe.linux-x86_64-2.7/library.zip/lib/MenuItem.py:13:   RuntimeWarning: use font: libSDL_ttf-2.0.so.0: cannot open shared object file: No such file or directory
(ImportError: libSDL_ttf-2.0.so.0: cannot open shared object file: No such file or directory)
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
File "rungame.py", line 10, in <module>
File "/lib/gameloop.py", line 13, in <module>
File "/lib/settings.py", line 10, in <module>
File "/lib/menuitem.py", line 13, in <module>
File "/usr/lib64/python2.7/site-packages/pygame/__init__.py", line 74, in __getattr__
NotImplementedError: font module not available
(ImportError: libSDL_ttf-2.0.so.0: cannot open shared object file: No such file or directory)
Run Code Online (Sandbox Code Playgroud)

在我编译二进制文件的机器上运行正常.有人可以建议我吗

vwv*_*dya 10

运行这个: sudo apt-get install libsdl-ttf2.0-0

  • @YanickRochon,我遇到了和你一样的问题(因为已经安装了“libsdl-ttf2.0-0”)。这终于对我有用了:`sudo apt-get install python3-sdl2` (5认同)
  • 这对我不起作用。`libsdl-ttf2.0-0` 已安装 (2认同)