更新1:我已经卸载、重新安装并按照Pygame网站上的说明安装依赖项/构建Pygame。结果发现我缺少依赖项,因为当我尝试运行setup.py脚本时,Python会提示。
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位。 Cinnamon 版本:2.6.13。 显卡: Intel Corporation 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。[在研究另一篇帖子后得知,如果不设置此变量,pygame将无法正常工作]
>~set | grep 'SDL'
SDL_VIDEODRIVER=x11
< p >[补充一下之前的内容:我运行了一个简单的编译好的C文件,演示了在libSDL中呈现图像的窗口,这个可以工作得很好!]< /p>
< p >在双重检查libSDL已安装/驱动器的环境变量已设置之后,我下载了三个不同的游戏从pygame网站。这个特定的错误仍然存在。我被卡住了,需要任何帮助来解决这个问题并让pygame正常工作。非常感谢您的时间。< /p>
apt-get install python-pygame
。没有想到使用其他的安装方法。也许我会尝试一下其他的方法。不过似乎已经成功安装了,因为我能够运行 Python 然后输入import pygame; pygame.init()
,而不是得到一个错误。谢谢! - JLP1990