I'm following this tutorial here to make a snakegame in pygame. Here is my setup.py code:
import cx_Freeze
executables = [cx_Freeze.Executable("snake.py")]
cx_Freeze.setup(
name="Snake",
options={"build_exe":{"packages":["pygame"], "include_files":["apple.png","Aenemy.png","bomb.png","cherry.png","enemy.png","fire.png","iceimg.png","snakebod(2).png","snakebod.png","Explosion.wav","Explosion2.wav","jump.wav","Pickup_Coin.wav","Powerup.wav","openingsong.mp3","highscores.txt",]}},
description = "Snake Game made in python with pygame.",
executables = executables
)
When I try to build that in the command prompt I get this error
C:\Users\Accounts\Documents\snake>C:/Python35/python setup.py build running build running build_exe File "C:\Python35\lib\site-packages\cx_Freeze\hooks.py", line 597, in load_tkinter tclSourceDir = os.environ["TCL_LIBRARY"]
File "C:\Python35\lib\os.py", line 681, in getitem raise KeyError(key) from None KeyError: 'TCL_LIBRARY'KeyError: 'TCL_LIBRARY'
and it doesn't build. Does anyone know how to fix this? Thanks
I was getting a similar error and solved it successfully this morning! Add following lines to your setup.py code
import os
os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Python35\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Program Files\\Python35\\tcl\\tk8.6"
you may need to replace C:\Program Files\Python35\tcl\tcl8.6 and C:\Program Files\Python35\tcl\tk8.6 with the exact path of tcl8.6 and tk8.6 on your system respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With