2

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?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Ash
  • 21
  • 2

1 Answers1

2

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!

srattigan
  • 665
  • 5
  • 17
Goatath
  • 21
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 24 '22 at 06:27
  • If you have ever used replit you would know that this answer is not unclear – Goatath Mar 25 '22 at 04:47
  • I've been using replit and the answer was enough to let me know what the problem was- I didn't realise there were so many templates just for Python. To further confuse the issue, I had been using the "standard" Python template for months now and adding the pygame package - with success - until recently I also began to receive this error. – srattigan Apr 07 '22 at 16:28