0

Title says it all. In Sublime Text, the code (the Alien Invasion one) from Python Crash Course by Eric Matthes works, the displays show up, and you can interact and play with it. On the other hand, VS Code (which has the Anaconda Extension), a black window shows up for a second, then immediately closes afterwards. I am required to use VS Code as a main code editor and cannot switch to Sublime Text. Here's the logs: pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "c:/Users/tuque.LAPTOP-INJ088N0/Documents/Dedge Python Scripts/scoring/alien_invasion.py", line 257, in <module> File "c:/Users/tuque.LAPTOP-INJ088N0/Documents/Dedge Python Scripts/scoring/alien_invasion.py", line 31, in __init__ self.sb = Scoreboard(self) File "c:\Users\tuque.LAPTOP-INJ088N0\Documents\Dedge Python Scripts\scoring\scoreboard.py", line 25, in __init__ self.prep_ships() File "c:\Users\tuque.LAPTOP-INJ088N0\Documents\Dedge Python Scripts\scoring\scoreboard.py", line 66, in prep_ships ship = Ship(self.ai_game) File "c:\Users\tuque.LAPTOP-INJ088N0\Documents\Dedge Python Scripts\scoring\ship.py", line 16, in __init__ self.image = pygame.image.load('images/ship.bmp') pygame.error: Couldn't open images/ship.bmp

edit: Also tried projects made by other users with pygame, same results. edit2: VS Code Python Version is 3.7.2 'conda' while Sublime Text is 3.8

  • 2
    Pygame can't find the image in `images/ship.bmp`. Make sure it's really there. The images folder needs to be in the same folder as `alien_invasion.py`, which would be in `c:/Users/tuque.LAPTOP-INJ088N0/Documents/Dedge Python Scripts/scoring/` – Captain Jack Sparrow Apr 29 '20 at 12:39
  • the file _ship.bmp_ is already in the right folder, which is why it worked in Sublime Text. Also tried other projects with pygame in it, same results. – Leatherback Apr 29 '20 at 12:57
  • Then the python interpreter is started using the wrong working directory – sloth Apr 29 '20 at 14:09
  • Also: https://stackoverflow.com/questions/53553272/pygame-error-couldnt-open-image-png-only-in-command-prompt – sloth Apr 29 '20 at 14:12

0 Answers0