“pygame.error:没有可用的视频设备”在复制上

发布于 2025-01-16 23:41:15 字数 837 浏览 3 评论 0原文

我不断收到错误:pygame.error:没有可用的视频设备。 这适用于在 Windows 上安装 python 3.10 时出现的 python 默认 IDLE,但不适用于 Replit(Online IDLE)。

我将 pygame 安装到 Relpit 中,如你所见 此处

我从这部分代码中收到错误:

import pygame
import math
pygame.init()

WIDTH, HEIGHT =  800, 800
WIN = pygame.display.set_mode((WIDTH, HEIGHT))  <<<-- ERROR LINE
pygame.display.set_caption("Planet Simulation")

这是输出:

pygame 2.1.2 (SDL 2.0.16, Python 3.8.12)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "main.py", line 6, in <module>
    WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.error: No available video device

所以我的问题是,这是 IDLE 故障还是代码错误。另外我该如何修复它?

I keep receiving Error: pygame.error: No available video device.
This works on python default IDLE that comes when installing python 3.10 on Windows but doesn't work with Replit(Online IDLE).

I installed pygame into Relpit as you can see
here

I'm getting Error from this part of the code:

import pygame
import math
pygame.init()

WIDTH, HEIGHT =  800, 800
WIN = pygame.display.set_mode((WIDTH, HEIGHT))  <<<-- ERROR LINE
pygame.display.set_caption("Planet Simulation")

This is the the Output:

pygame 2.1.2 (SDL 2.0.16, Python 3.8.12)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "main.py", line 6, in <module>
    WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.error: No available video device

So my question is, Is this the IDLE fault or is the code wrong. Also How do I fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面如桃花 2025-01-23 23:41:15

查找制作新的 repl 时的 PyGame 模板

使用 repllit,您必须确保使用提供的 pygame 模板 - 您可以从提供的链接中搜索该模板 - 创建“特殊项目”时非常简单:

  1. 制作一个新的项目
  2. 选择PyGame template
  3. 将您的代码复制到新项目中

,它应该可以修复它!

Find the PyGame template when making a new repl

With replit you have to make sure to use the provided pygame template - which you can search for from the link provided - when creating a "special project" so simply:

  1. Make a new project
  2. Select the PyGame template
  3. copy your code into the new project

and it should fix it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文