0

OS is windows

Terminal => Windows Subsystem For Linux

Ps: When I run it through Windows PowerShell it runs, but I want to run it through ubuntu, because I use ubuntu not Windows PowerShell

I know that there is a lot of similar questions on stackoverflow to mine, but it is not working. Problem is I am trying to run the code and I am getting this error

Traceback (most recent call last): File "/mnt/c/Users/owner/Desktop/Projects/games/tic-tac-toe/tic_tac_to.py", line 11, in screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.error: No available video device

My code:

import pygame, sys

pygame.init()

# Const variables
WIDTH = 600
HEIGHT = 600
RED = (255,0,0)
BACKGROUND_COLOR = (20, 189, 172)

screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("TIC-TAC-TOE")
screen.fill(BACKGROUND_COLOR)

# mainloop
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
    pygame.display.update()
  • We need to know a lot more than your code to identify this -- it may even be off-topic here if it's a system administration problem more than a software development problem. – Charles Duffy Aug 03 '21 at 14:04
  • First: Which SDL backend are you trying to use? (X11? Weyland? Framebuffer?) – Charles Duffy Aug 03 '21 at 14:04
  • Second: If it's the X11 backend, can you successfully start `xclock` or `xterm` from the same window or script? Is your copy of SDL _actually compiled_ with the X11 backend enabled? (To be clear, the follow-up questions I'm asking here are better fit to a [unix.se] problem than a Stack Overflow one, but so far we've been given no reason to believe that it _is_ a Stack Overflow problem). – Charles Duffy Aug 03 '21 at 14:06
  • Can you run other pygame applications, written by someone else? – Charles Duffy Aug 03 '21 at 14:06
  • Also, _which version_ of WSL is this? – Charles Duffy Aug 03 '21 at 14:06
  • @CharlesDuffy When I open through WSL it does not run and gives me this error, but when I open it through Windows PowerShell it runs perfect. – Hamza Tanya Aug 03 '21 at 14:12
  • Again, which version of WSL? X11 support wasn't added until WSL 2. – Charles Duffy Aug 03 '21 at 14:31
  • The Version is 2 – Hamza Tanya Aug 03 '21 at 14:58

0 Answers0