0

My code works perfectly fine when executed from IDLE. I used cx_Freeze to compile my python code into an executable application and now it wont run. I've added my "setup.py" code below. I have also provided the result of running the program from command prompt.

from cx_Freeze import setup, Executable
import os


os.environ['TCL_LIBRARY'] = r'C:\Program Files (x86)\Microsoft Visual 
Studio\Shared\Python36_64\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files (x86)\Microsoft Visual 
Studio\Shared\Python36_64\tcl\tk8.6'

build_exe_options = {"packages": ["numpy"]}

setup(name= 'Current-Translator',
      version = '1.0',
      description = 'Convert and plot electrical current data from data logger.',
      options = {"build_exe": build_exe_options},
      executables = [Executable('Current-Translator.py')])

Command Prompt Output

Traceback (most recent call last):


File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "Current-Translator.py", line 6, in <module>
  File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\timedelta\__init__.py", line 9, in <module>
    @public.add
  File "C:\Users\jchoujaa\AppData\Local\Programs\Python\Python37\lib\site-packages\public\__init__.py", line 65, in add
    return _add(_caller_modules()[1], objects)
IndexError: list index out of range
Juicy
  • 25
  • 8
  • Please post the error message with full stack trace (command prompt output) as text, not as an image. See [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/q/285551/8516269) – jpeg Feb 07 '19 at 07:29

1 Answers1

0
  1. Try to use the following build_exe options in your setup script:

    build_exe_options = {"packages": ["numpy", "public", "timedelta"]}
    
  2. It seems like you are using cx_Freeze with python 3.7, apparently without further problem. cx_Freeze does not yet support Python 3.7, it has a bug (for some system configurations only?). 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.

jpeg
  • 2,372
  • 4
  • 18
  • 31
  • I tried adding the 'build_exe' options, no luck there. Probably would have more luck using python 3.6. – Juicy Feb 07 '19 at 15:37