I've got a very simple python program I wrote to learn pygame, and among other things I use an image.
When I run the program with PyCharm, or when I run it by double-clicking on the file, it works fine. However, if I try to run it through the command prompt, I get the following error:
C:Usersjulix>C:UsersjulixDocumentsestpygame_tutorial.py
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "C:UsersjulixDocumentsestpygame_tutorial.py", line 21, in <module>
carImg = pygame.image.load("racecar.png")
pygame.error: Couldn't open racecar.png
This is the line in my code it refers to:
carImg = pygame.image.load("racecar.png")
The image "racecar.png" is located in exactly the same directory as the program.
The confusing part is that my code seems to be fine since there are no errors when I run it by double-clicking.
Can post full code if necessary.
Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…