2

I am using python 3.5.1 and the unofficial cx_freeze 5.0 build available from here. I am trying to create an executable version of a python project using tkinter and sympy that I've been working on. I used cxfreeze-quickstart to create a setup.py file for the program, and in terms of building what at least seems to be a valid executable, it works without throwing any errors. However, when I try to run the executable, nothing happens. I know similar questions have been asked on here and I've looked at and tried to understand every one I've found, but none of the solutions have worked for me. I don't understand what's going on, and any help would be appreciated. Code below:

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [
    Executable('c:\\users\\joe\\pycharmprojects\\physics2-0\\physics2-0.py', base=base,
           targetName = 'c:\\users\\joe\\pycharmprojects\\physics2-0\\physics.exe')
]

setup(name='physics solver',
      version = '0.1',
      description = 'alpha physics solver',
      options = dict(build_exe = buildOptions),
      executables = executables)

Thanks in advance.

UPDATE: I am now attempting to write the setup.py script myself according to the template provided in the docs, although any help would still be greatly appreciated.

UPDATE 2: I wrote my own setup.py according to the template provided in the docs, and put it in the same folder as the script I want to freeze, something I hadn't realized I needed to do. I ran python setup.py build in command line, and it created the build subdirectory with the exe and DLLs. However, now when I try and run the exe, an error message pops up that says ImportError: DLL load failed. The specified module could not be found. in reference to tkinter. The code for the 2nd setup.py is below.

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["tkinter", "sympy", "_tkinter"],     "excludes": []}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == 'win32':
    base = "Win32GUI"

setup(  name = "physics solver",
        version = "0.1",
        description = "a basic physics solver",
        options = {"build_exe": build_exe_options},
        executables = [Executable("Physics2-0.py", base=base)])

Below are the first 4 lines of physics2-0.py. The line brought into question by the error message is line 1.

from tkinter import *
from tkinter import ttk
from sympy import Symbol
from sympy.solvers import solve

UPDATE 3: Someone please help me out here. I can't figure this out. I've even done a clean re-install of python at this point, just to be sure I didn't accidentally mess something up at some point, and it's still giving me the same error message.

  • Providing a [mcve] might be useful. Now it is not clear if your code imports for example numpy, which may cause trouble with cx_Freeze as described in an [answer](http://stackoverflow.com/a/34893933/5781248) for a cx_Freeze related problem. – J.J. Hakala Jun 21 '16 at 23:55
  • @J.J.Hakala Sorry, I didn't realize I forgot to include the code for the 2nd setup script. I'll go and see if I can figure out if it's importing numpy.EDIT: It does seem to be importing numpy, yes, but I think sympy has some dependencies on numpy. I'll try excluding numpy though, and see what happens. – Adam Cochrane Jun 22 '16 at 00:03
  • @J.J.Hakala Excluding numpy had no apparent effect, although I will test again. The problem, I think, lies elsewhere. – Adam Cochrane Jun 22 '16 at 00:10
  • That `ImportError` happens when the code in *Physics2-0.py* is executed. Giving an answer to your question might be impossible since the code in *Physics2-0.py* is unavailable. – J.J. Hakala Jun 22 '16 at 00:10
  • @J.J.Hakala I've added the first 4 lines of physics2-0.py to the original post. should be enough, as line 1 is the line referenced in the error. – Adam Cochrane Jun 22 '16 at 00:15

0 Answers0