pygame 项目将无法运行:“pygame.error: No available video device"; [英] pygame projects won't run: "pygame.error: No available video device"

查看:152
本文介绍了pygame 项目将无法运行:“pygame.error: No available video device";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新 1:我卸载、重新安装并按照 Pygame 网站上的说明安装依赖项/构建 Pygame.事实证明我缺少依赖项,正如 Python 在我尝试运行 setup.py 脚本时指出的那样:

UPDATE 1: I uninstalled, reinstalled, and followed the instructions on the Pygame website for installing dependencies/building Pygame. It turns out I'm missing dependencies, as Python indicates when I attempt to run the setup.py script:

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

我在别处有一份清单,列出了与缺少的软件包对应的内容.我的问题是:我需要修改什么环境变量才能检测到这些包?(并且,这样做时,我需要提供什么?每个文件的共享对象文件?)

I have a list elsewhere of what corresponds the what missing package. My question is: what environment variable will I need to modify in order to get these packages detected? (and, when doing so, what will I need to provide? the shared object file for each of these?)

系统详细信息 - Linux Mint 17.2 Cinnamon 64 位.肉桂版:2.6.13.显卡:Intel Corporation Broadwell-U 集成显卡.7.7 GiB 内存,i5 处理器.

System details - Linux Mint 17.2 Cinnamon 64-bit. Cinnamon version: 2.6.13. Graphics card: Intel Corporation Broadwell-U Integrated Graphics. 7.7 GiB Memory, i5 processor.

我正在尝试在我的新设备上启动并运行 pygame 以制作一些游戏.我最近安装了 libSDL 和 pygame;在尝试运行其他人制作的三个不同的游戏后,我一直遇到同样的错误:

I am trying to get pygame up and running on my new device to make some games. I installed libSDL, and pygame more recently; after trying to run three different games others have made, I keep running into the same error:

>~/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

我为调查问题/尝试解决问题所做的工作:

What I did to look into the issue/try to resolve it:

1) 仔细检查我已经安装了 libSDL 和相应的开发包.[在研究此错误的一个原因是没有安装 libSDL 后]

1) Double checked I have libSDL and the corresponding dev packages installed. [after researching that one cause of this error is not having libSDL installed]

>~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不能正常运行]

2) Ensured I had the appropriate envvar for SDL_VIDEODRIVER set. [after researching another post, indicating that this variable needs to be set or pygame will not work properly]

>~set | grep 'SDL'
SDL_VIDEODRIVER=x11

[添加到前者:我运行了一个简单的编译后的 .c 文件,演示了一个在 libSDL 中呈现图像的窗口,并且效果很好!]

[To add to the former: I ran a simple compiled .c file demonstrating a window with image rendered on it in libSDL, and that works just fine!]

在仔细检查安装了驱动程序的 libSDL/envvar 后,我从 pygame 站点下载的三个不同的游戏仍然存在此特定错误.我在这一点上很难过,希望能得到有关如何解决这个问题并使 pygame 正常工作的任何帮助.非常感谢您抽出宝贵时间.

After double checking libSDL is installed/envvar for the driver is set, this particular error persists for three different games I downloaded from the pygame site. I'm pretty stumped at this point, and would appreciate any help on how resolve this and get pygame working. Many thanks for your time.

推荐答案

这是来自问题;已移至此处以进一步公开答案.

This is from the question; it's been moved here to further expose the answer.

好的.我让 pygame 在我的 Linux 安装上工作.由于一个无关的原因,我不得不重新分区,但我想在这样做之后我在新安装中遵循了这些步骤,并最终使其正常工作:(链接描述了下面的头文件问题,libv4l-dev)

Alright. I got pygame to work on my Linux installation. I had to repartition for an unrelated reason, but I guess after doing so I followed these steps on a new install, and finally got it working: (link describing the header file issue below, libv4l-dev)

  1. 通过在命令行中输入以下内容来安装所有依赖项:~> apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
  2. 运行 SDL 配置命令:~> sdl-config --cflags --libs
  3. 进入pygame-1.9.1release文件夹,运行:~> python config.py看看我缺少什么依赖项(如果有的话).在这一点上,我错过了:SMPEG、PORTMIDI 和 PORTTIME.我只是查看了这些并使用Synaptic 软件包管理器.
  4. 之后再次运行 python config.py 显示我有所有必需的依赖项.
  5. 然后我运行了 sudo python setup.py install 并遇到了一些错误关于找不到头文件.找到另一个StackExchange 帖子详细介绍了如何解决此特定问题:~> sudo apt-get install libv4l-dev~> cd/usr/include/linux~> sudo ln -s ../libv4l1-videodev.h videodev.h
  6. 再次运行 sudo python setup.py,它成功了.通过运行python确认这一点,然后检查版本import pygame 然后是 pygame.version.ver()...并快速运行其他人制作的游戏.
  1. Install all the dependencies by entering this on the command line: ~> apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
  2. Run the SDL configuration command: ~> sdl-config --cflags --libs
  3. Enter the folder for pygame-1.9.1release, and run: ~> python config.py to see what, if any, dependencies I was missing. At this point, I was missing: SMPEG, PORTMIDI and PORTTIME. I just looked these up and downloaded them using Synaptic Package Manager.
  4. Running python config.py again afterwards showed I had all required dependencies.
  5. I then ran sudo python setup.py install and got some errors about a header file not being found. Found another StackExchange post detailing how to resolve this particular issue: ~> sudo apt-get install libv4l-dev ~> cd /usr/include/linux ~> sudo ln -s ../libv4l1-videodev.h videodev.h
  6. Ran sudo python setup.py again, and it worked. Confirmed this by running python, then checking the version import pygame followed by pygame.version.ver()... and quickly running a game someone else made.

这篇关于pygame 项目将无法运行:“pygame.error: No available video device";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆