love code
love code

Reputation: 87

How to fix this error occurred while using .png image in visual studio code?

As you can see python code I am trying to add .png image in my program but when I try it shows me error

The below error is shown by interpreter-

An error occurred while loading the image

open file using VS code's standard text/binary/editor?

 import pygame

 #initialize pygame

 pygame.init()


 #create the game screen

 screen = pygame.display.set_mode((800,600))


 # title and icon

 pygame.display.set_caption("space invaders")

 icon = pygame.image.load('spaceship.png')

 pygame.display.set_icon(icon)



# game loop

running = True

while running:

for event in pygame.event.get():

 if event.type == pygame.QUIT:

 running = False

Upvotes: 0

Views: 4180

Answers (1)

lorenzozane
lorenzozane

Reputation: 1279

Unfortunately it is a known and reported bug on the official repo of VS Code. I invite you to read the comments but unfortunately the issue has been closed and there doesn't seem to be a definitive solution. Someone claims that it doesn't happen all the time and that by restarting VS Code it was able not to run into the error.

Here you can see that it has been reported several times already:

Upvotes: 1

Related Questions