r/learnpython • • Sep 05 '20

ASSALAMU'ALAIKUM, CAN YOU HELP ME!

assalamu'alaikum, I am a beginner in this matter I want to ask why when I change my python file to exe it works, but when opened it says like this:

Traceback (most recent call last):

File "C:\Users\HP\anaconda3\lib\runpy.py", line 183, in _run_module_as_main

mod_name, mod_spec, code = _get_module_details(mod_name, _Error)

File "C:\Users\HP\anaconda3\lib\runpy.py", line 109, in _get_module_details

__import__(pkg_name)

File "C:\Users\HP\corona\Destroythecovid19.py", line 408, in <module>

background = pygame.image.load(path.join(img_dir, "background/corona2.")).convert()

pygame.error: Couldn't open C:\Users\HP\corona\image\background/corona2.

0 Upvotes

1 comment sorted by

5

u/hassium Sep 05 '20

Hello, change this:

pygame.image.load(path.join(img_dir, "background/corona2.")).convert()

To this:

pygame.image.load(path.join(img_dir, "background\corona2.FILETYPE")).convert()

You have the slash the wrong way around and you need to replace FILETYPE with the file extension of the image (.jpg, .img etc...)