Python and Output Bugs This Week

Problem description

In working with my students this week, we have noticed several problematic behaviors.

First, when creating a new Python Replit, Flask code is automatically included in the project at creation. This is a new problem and it seems this should not be happening.

Second, for some of my students, the option for “Output” is missing from their left-hand menu toolbar.

Finally, in working on a Pygame project, we are encountering a backend bug: libGL error: MESA-LOADER: failed to open swrast; GLIBC_2.38 not found, etc. These Replits were all functioning properly yesterday.

In short, it seems like the development team has made some changes that are causing unexpected behaviors this week.

Expected behavior

  1. New Python Replits should not include boilerplate Flask code when they are not themselves Flask projects.
  2. Output windows should be options in the Toolbar.
  3. Pygame programs should be able to display output without errors.

Actual behavior

Please see my description above.

Steps to reproduce

Try running the following code:

import pygame

pygame.init()

class Player:

  def __init__(self,
              x,
              y,
              width,
              height,
              screen_height):
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.screen_height = screen_height
    self.velocity = 0
    self.gravity = 0.25
    self.jump_height = -10

 
  def jump(self):
    if self.y == self.screen_height - self.height:
      self.velocity = self.jump_height

  def update(self):
    self.velocity += self.gravity
    self.y += self.velocity
    
    # Check for ground using self.screen_height
    if self.y > self.screen_height - self.height:
      self.y = self.screen_height - self.height

  def draw(self, screen):
    pygame.draw.rect(screen, 
                     (255, 0, 0),
                     (self.x, 
                      self.y, 
                      self.width,
                      self.height))


class Game:

  def __init__(self):
    pygame.init()
    self.screen_width, self.screen_height = 800, 600
    self.screen = pygame.display.set_mode(
        (self.screen_width, self.screen_height))
    self.clock = pygame.time.Clock()
    self.player = Player(self.screen_width // 2,
                         self.screen_height - 50,
                         50,
                         50,
                         self.screen_height)
    self.running = True

  def run(self):
    while self.running:
     for event in pygame.event.get():
      if event.type == pygame.QUIT:
       self.running = False
      if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_SPACE:
          self.player.jump()
    
     self.player.update()
     self.screen.fill((135, 206, 250))
     self.player.draw(self.screen)
    
     pygame.display.flip()
     self.clock.tick(30)

  def __del__(self):
    pygame.quit()
  

if __name__ == "__main__":
 game = Game()
 game. Run()

Browser

Google Chrome

OS

Chrome OS

Device if mobile

Chromebook

Plan

Free Tier

Welcome to Ask @StephenSeverino!

See this topic: New Python Project Bug

2 Likes

Hello,
first, replit has for some reason decided to put flask example code in the default python template… A bug report as seen in the previous post was created about this.

Second, the Output window usually opens automatically when the program is run and displays stuff. The Output tool will not be present in most repls until, I think, the Output has been opened automatically at least once.
(If there is a There was an error connecting to the server problem, then either the *.replit.dev domain is blocked or the Output needs to be refreshed while the program is running.)

Finally, which template are you using for your pygame projects? Are there any other installed packages?
Please share a link to a public repl which reproduces the issue, if possible.

For currently broken pygame repls, I believe the following fix might help:
Click three dots and Show hidden files, then open .replit file (not replit.nix).
Find the channel variable and change it from "stable-23_05" to "stable-23_11" , then reload.

(A note about your pygame code, you should avoid using the __del__ method in general.)

1 Like