0

I've been trying to get this to work for a while and this error means I have made 'progress'. I'm using Python2.7 and Pygame.

UPDATE:

I fixed this issue by changing File to sys.argv[0]

C:\Python27\dist>Space_Badgers.exe
Traceback (most recent call last):
File "Space_Badgers.py", line 16, in <module>
NameError: name '__file__' is not defined

#This is the code its referring to:

img_dir = path.join(path.dirname(__file__), "img")

Please help, I wouldn't have guessed converting to exe would be so difficult.

Though, I am still new to programming.

UPDATE:

C:\Python27\dist>Space_Badgers.exe
Traceback (most recent call last):
File "Space_Badgers.py", line 163, in <module>
pygame.error: Couldn't open img\10121.png

This is my new issue. It still runs fine in IDLE.

Tea-We
  • 13
  • 3
  • 1
    Please refer this question. http://stackoverflow.com/questions/2292703/how-can-i-get-the-executables-current-directory-in-py2exe – Vibhutha Kumarage Dec 10 '16 at 18:50
  • That did fix my issue thank you! I'm running into an issue now where it cant open an image that was packaged by py2exe now. – Tea-We Dec 10 '16 at 20:41

0 Answers0