Mailing List Archive

'Pygame Module' not working
Hi,
I am a beginner in Python and I have started with the 'Pygame' module. I
was making a 'Flappy Bird' game with the module with the help of Youtube
videos. I was able to create a blank window. I had downloaded the game
assets in my computer in a folder called 'Python' and in a subfolder called
'assets'. I tried to upload the Flappy Bird picture and other sprites with
the code -
pygame.image.load('assets/Flappy Bird.png')
However, when I ran the script it was showing an error message - File not
found
Please advise me on how to upload the sprites and where I was going wrong.
Thank You,
Regards
--
https://mail.python.org/mailman/listinfo/python-list
Re: 'Pygame Module' not working [ In reply to ]
On Sat, 31 Jul 2021 14:07:05 +0530, 37_VA_VEER CHAKRABORTY
<veerchakraborty612@gmail.com> declaimed the following:

>pygame.image.load('assets/Flappy Bird.png')
>However, when I ran the script it was showing an error message - File not
>found
>Please advise me on how to upload the sprites and where I was going wrong.

First attempt: use a full pathname.

Second: determine what the "current working directory" is in which your
program is running, then use a pathname relative to that directory.


--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list
Re: 'Pygame Module' not working [ In reply to ]
On 31/07/2021 03.37, 37_VA_VEER CHAKRABORTY wrote:
> Hi,
> I am a beginner in Python and I have started with the 'Pygame' module. I
> was making a 'Flappy Bird' game with the module with the help of Youtube
> videos. I was able to create a blank window. I had downloaded the game
> assets in my computer in a folder called 'Python' and in a subfolder called
> 'assets'. I tried to upload the Flappy Bird picture and other sprites with
> the code -
> pygame.image.load('assets/Flappy Bird.png')
> However, when I ran the script it was showing an error message - File not
> found

Are you running your program in the parent directory of "assets"?

What happens when you go into the python interpreter (REPL) and import
pygame followed by executing that function?


--
Michael F. Stemper
Why doesn't anybody care about apathy?
--
https://mail.python.org/mailman/listinfo/python-list
Re: 'Pygame Module' not working [ In reply to ]
On 2021-07-31 20:46, Dennis Lee Bieber wrote:
> On Sat, 31 Jul 2021 14:07:05 +0530, 37_VA_VEER CHAKRABORTY
> <veerchakraborty612@gmail.com> declaimed the following:
>
>>pygame.image.load('assets/Flappy Bird.png')
>>However, when I ran the script it was showing an error message - File not
>>found
>>Please advise me on how to upload the sprites and where I was going wrong.
>
> First attempt: use a full pathname.
>
> Second: determine what the "current working directory" is in which your
> program is running, then use a pathname relative to that directory.
>
The path of the program itself should be in __file__. You can then use
os.path.dirname to get the path of its folder and os.path.join to build
a path from that to the image file.
--
https://mail.python.org/mailman/listinfo/python-list