5

My program is working in anaconda spyder. however, after freezing it all widgets that use the tkinter module work except for the widget with xgboost and pandas. No error showed, the build worked but the button is not working and not showing the widget.

I've tried importing and including xgboost in my setup.py file but all other widgets with tkinter didn't work altogether. No error still though. have anyone experienced or solved this issue?

Here's the closest thing that worked. This is my setup.py, when the other widgets worked with tkinter but not the one with xgboost and pandas.

from cx_Freeze import setup, Executable
import sys
import os

includes = []
include_files = [r"C:/Users/USER/Anaconda3/DLLs/tcl86t.dll",
         r"C:/Users/USER/Anaconda3/DLLs/tk86t.dll",
         r"C:/Users/USER/SAMPLE/xgboost_USE.model",
         r"C:/Users/USER/SAMPLE/P1.ico"]
os.environ['TCL_LIBRARY'] = "C:/Users/USER/Anaconda3/tcl/tcl8.6"
os.environ['TK_LIBRARY'] = "C:/Users/USER/Anaconda3/tcl/tk8.6"
base = 'Win32GUI' if sys.platform == 'win32' else None


setup(name=application_title, version='1.0', description='SAMPLE',
      options={"build_exe": {"includes": includes, "include_files":                 
      include_files}},executables=
      [Executable(r'C:/Users/USER/SAMPLE/sample.py', base=base)])

Please help.

Xantium
  • 11,201
  • 10
  • 62
  • 89
jp-tech
  • 91
  • 7
  • Try running your application through the terminal this will show any errors. Also could you please mention what platform you are working on. – Xantium Dec 17 '17 at 18:30
  • 1
    I am using python. No errors in anaconda python console when i ran the main program there but after freezing one of the widgets is not showing. The one with xgboost. – jp-tech Dec 18 '17 at 00:45

1 Answers1

0

I dont have any experience with xgboost but I know when you cx freeze pandas you will need to explicitly include numpy. I'll share a setup file I have that has pandas (and some other things you can delete out like boto I assume)

import sys
import cx_Freeze
import os.path
import scipy

base = None

if sys.platform == 'win32':
    base = "Win32GUI"

#This part may depend on where your installation is
#This part is essential to copy the tkinter DLL files over
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
os.environ['REQUESTS_CA_BUNDLE'] = r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore\vendored\requests\cacert.pem'


executables = [cx_Freeze.Executable("test.py", base=base)]
addtional_mods = ['numpy.core._methods', 'numpy.lib.format']

packages = ["idna", "numpy", "boto3", 'boto3.s3.transfer', 'boto3.s3.inject', 'multiprocessing', "xlwt", 'numpy.core._methods', 'pandas']
options = {
    'build_exe': {

        'include_files':[
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
            os.path.dirname(scipy.__file__),
            r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore\vendored\requests\cacert.pem',
            r'C:\ProgramData\Anaconda3\Lib\site-packages\botocore',

         ],
        'includes': addtional_mods,
        'packages':packages,
    },

}

cx_Freeze.setup(
    name = "Test",
    options = options,
    version = "1.0.0.0",
    description = 'Test',
    executables = executables
)
Gardener85
  • 369
  • 1
  • 9
  • Thank you. I added xgboost as a package but it can't find the module. Also, im thinking, even if xgboost is not working the widget must show. But i've used tkinter with my other widgets and it's working just fine. I don't know what to do anymore. – jp-tech Dec 19 '17 at 05:18
  • Also i've used in my main program #from pandas.api.types import CategoricalDtype# does this need to be explicitly included aside from the #pandas# in packages in setup.py? – jp-tech Dec 19 '17 at 05:37
  • Not finding xgboost would definitely be a problem while trying to freeze it. as for pandas I think so long as you have pandas and the numpy related things I added in like addtional_mods = ['numpy.core._methods', 'numpy.lib.format'] and packages = ['numpy', 'numpy.core._methods', 'pandas'] it should work. – Gardener85 Dec 20 '17 at 06:09
  • i tried searching for xgboost and cx_freeze but not finding much. I have had issues where installations were done as unpacked eggs and cx freeze didnt like that. Sometimes doing a pip install upgrade of that module can help. – Gardener85 Dec 20 '17 at 06:11