Search code examples
pythoncmdexepython-3.6cx-freeze

cx_freeze executable not working when I run through cmd in python


Hi I have converted my script to exe using cx_freeze but when I am running its not working as expected

My script:cmd.py

import sys
import pandas as pd
import numpy as np


for arg in sys.argv:
    print (arg)
print ("Hello World!")

my setup.py

having both the scripts in same folder

import sys,os
from cx_Freeze import setup, Executable

os.environ['TCL_LIBRARY'] = r'C:\ProgramData\Anaconda3\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\ProgramData\Anaconda3\tcl\tk8.6'

setup(
    name = "On Dijkstra's Algorithm",
    version = "3.1",
    description = "A Dijkstra's Algorithm help tool.",
    executables = [Executable("cmd.py", base = "Win32GUI")])    

A folder named build is created with cmd.exe but when I am running the below line in cmd

cmd one two nothing is happening, Please help


Solution

  • You set the base of your Executable as a Win32GUI which means that it is supposed to be a GUI only with no console. By doing this, Windows does not make stout and stderr available, and your prints go to the mysterious land of unprinted pages (in other words, they are lost).

    You should use the base="Console" to be able to see your prints.