【发布时间】:2015-12-08 14:41:31
【问题描述】:
更新 1:我卸载、重新安装并按照 Pygame 网站上的说明安装依赖项/构建 Pygame。事实证明我缺少依赖项,正如 Python 在我尝试运行 setup.py 脚本时所指示的那样:
SDL : found 1.2.15
FONT : not found
IMAGE : not found
MIXER : not found
SMPEG : found 0.4.5
PNG : not found
JPEG : not found
SCRAP : not found
PORTMIDI: found
PORTTIME: found
我在别处有一个列表,列出了缺少的包对应的内容。我的问题是:我需要修改什么环境变量才能检测到这些包? (并且,这样做时,我需要提供什么?每个共享对象文件?)
编辑:系统详细信息 - Linux Mint 17.2 Cinnamon 64 位。肉桂版本:2.6.13。显卡:英特尔公司 Broadwell-U 集成显卡。 7.7 GiB 内存,i5 处理器。
我正在尝试在我的新设备上启动并运行 pygame 以制作一些游戏。我最近安装了 libSDL 和 pygame;在尝试运行其他人制作的三个不同游戏后,我一直遇到同样的错误:
>~/Downloads/bubble $ python run.py
Traceback (most recent call last):
File "run.py", line 2, in <module>
from classes.game import *
File "/home/---/Downloads/bubble/classes/game.py", line 2, in <module>
from .arrow import *
File "/home/---/Downloads/bubble/classes/arrow.py", line 1, in <module>
from .constantes import *
File "/home/---/Downloads/bubble/classes/constantes.py", line 35, in <module>
scr = display.set_mode(screen.size)
pygame.error: No available video device
我做了什么来调查这个问题/尝试解决它:
1) 仔细检查我已经安装了 libSDL 和相应的开发包。 [在研究了导致此错误的一个原因是未安装 libSDL]
>~aptitude search sdl | grep -F 'i '
i A libalien-sdl-perl - helper to get, build and use SDL libraries
i A libsdl-console - Console that can be added to any SDL appli
i libsdl-console-dev - Console that can be added to any SDL appli
i A libsdl-gfx1.2-4 - drawing and graphical effects extension fo
i libsdl-gst - SDL bindings for GNU Smalltalk
i libsdl-image-gst - SDL_image bindings for GNU Smalltalk
i libsdl-image1.2 - Image loading library for Simple DirectMed
i libsdl-image1.2:i386 - Image loading library for Simple DirectMed
i A libsdl-image1.2-dev - Image loading library for Simple DirectMed
i libsdl-mixer-gst - SDL_mixer bindings for GNU Smalltalk
i A libsdl-mixer1.2 - Mixer library for Simple DirectMedia Layer
i libsdl-mixer1.2:i386 - Mixer library for Simple DirectMedia Layer
i A libsdl-net1.2 - Network library for Simple DirectMedia Lay
i libsdl-net1.2:i386 - Network library for Simple DirectMedia Lay
i libsdl-net1.2-dbg - Network library for Simple DirectMedia Lay
i libsdl-net1.2-dev - Network library for Simple DirectMedia Lay
i A libsdl-pango1 - text rendering with Pango in SDL applicati
i libsdl-perl - SDL bindings for the Perl language
i A libsdl-sge - extension of graphic functions for SDL mul
i libsdl-sge-dev - extension of graphic functions for the SDL
i libsdl-sound-gst - SDL_sound bindings for GNU Smalltalk
i A libsdl-sound1.2 - Sound library for Simple DirectMedia Layer
i libsdl-ttf-gst - SDL_ttf bindings for GNU Smalltalk
i A libsdl-ttf2.0-0 - TrueType Font library for Simple DirectMed
i libsdl-ttf2.0-0:i386 - TrueType Font library for Simple DirectMed
i libsdl-ttf2.0-dev - TrueType Font library for Simple DirectMed
i A libsdl1.2-dev - Simple DirectMedia Layer development files
i libsdl1.2debian - Simple DirectMedia Layer
i libsdl1.2debian:i386 - Simple DirectMedia Layer
i A libsdl2-2.0-0 - Simple DirectMedia Layer
i libsdl2-dbg - Simple DirectMedia Layer debug files
i libsdl2-dev - Simple DirectMedia Layer development files
i libsdl2-gfx-1.0-0 - drawing and graphical effects extension fo
i libsdl2-gfx-dbg - debugging symbols for SDL2_gfx
i libsdl2-gfx-dev - development files for SDL2_gfx
i libsdl2-gfx-doc - documentation files for SDL2_gfx
i libsdl2-image-2.0-0 - Image loading library for Simple DirectMed
i libsdl2-image-dbg - Image loading library for Simple DirectMed
i libsdl2-image-dev - Image loading library for Simple DirectMed
i libsdl2-mixer-2.0-0 - Mixer library for Simple DirectMedia Layer
i libsdl2-mixer-dbg - Mixer library for Simple DirectMedia Layer
i libsdl2-mixer-dev - Mixer library for Simple DirectMedia Layer
i libsdl2-net-2.0-0 - Network library for Simple DirectMedia Lay
i libsdl2-net-dbg - Network library for Simple DirectMedia Lay
i libsdl2-net-dev - Network library for Simple DirectMedia Lay
i libsdl2-ttf-2.0-0 - TrueType Font library for Simple DirectMed
i libsdl2-ttf-dbg - TrueType Font library for Simple DirectMed
i libsdl2-ttf-dev - TrueType Font library for Simple DirectMed
2) 确保我为 SDL_VIDEODRIVER 设置了适当的 envvar。 [研究了另一篇帖子,提示这个变量需要设置,否则pygame将无法正常工作]
>~set | grep 'SDL'
SDL_VIDEODRIVER=x11
[补充一下:我运行了一个简单的编译后的 .c 文件,演示了一个在 libSDL 中呈现图像的窗口,效果很好!]
在仔细检查 libSDL 已安装/设置驱动程序的 envvar 后,对于我从 pygame 网站下载的三个不同游戏,此特定错误仍然存在。在这一点上,我很困惑,如果能帮助我解决这个问题并让 pygame 正常工作,我将不胜感激。非常感谢您的宝贵时间。
【问题讨论】:
-
您是否使用 apt-get 安装了 pygame?还是点子?或者通过运行 setup.py?我认为如果您使用 apt-get 它会“正常工作”......并且可能“pip”
-
我使用了
apt-get install python-pygame。我没有想到使用另一种安装方法。也许我会试试这些。似乎已经正确安装,因为我能够运行 python 然后输入import pygame; pygame.init()并返回一些东西而不是错误。谢谢! -
对不起,我无法提供更多帮助:/
-
如果你有时间和意愿,你可以考虑把你的问题分成一个回答帖子(你是如何解决的)和一个问题帖子(更新的问题,就像你解决它之前一样) .如果您没有有时间或意愿这样做,我很高兴您解决了这个问题! :D