Someone
Someone

Reputation: 55

How do I fix an Error when Freezing Python 3.7 Script using cx_Freeze

I am trying to create a standalone executable with my python script using cx_Freeze. This is the error I am getting: error: [Errno 2] No such file or directory: 'C:\\Program Files\\Python37\\tcl\\tcl8.6'

Does this have anything to do with using a module such as PySimpleGUI? I am using PySimpleGUI 3.1.2.

How do I fix this?

Here is my code (setup.py and Track_Companion.py).

Note: Track_Companion.py is not yet finished.

Upvotes: 3

Views: 1294

Answers (2)

jpeg
jpeg

Reputation: 2461

  1. cx_Freeze does not yet support Python 3.7, it has a bug. A bugfix exists but has not yet been released, however you can apply it manually, see What could be the reason for fatal python error:initfsencoding:unable to load the file system codec? and Cx_freeze crashing Python3.7.0. Or you can rollback to Python 3.6 if this is an option for you.
  2. Have you checked that C:\\Program Files\\Python37\\tcl\\tcl8.6 exists? It would anyway be better to let your setup script dynamically determine you Python installation directory using PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__)) as done in this answer.
  3. You need to tell cx_Freeze to include the Tcl and Tk DLLs using the build_exe option include_files as done in the same answer; if you are using cx_Freeze 5.1.1 or 5.1.0, you need to do it slightly differently, see this answer.

Upvotes: 2

Mike from PSG
Mike from PSG

Reputation: 5754

Instructions for making .EXE files from programs using PySimpleGUI can be found in the docs here.

To create the .EXE:

pyinstaller -wF yoursourcefile.py

I would upgrade your PySimpleGUI package prior to doing it.

Upvotes: 2

Related Questions