用cxfreeze-quickstart创建的.exe什么都不做 - cx_freeze 5.0

时间:2016-06-21 20:54:57

标签: python tkinter sympy cx-freeze

我正在使用python 3.5.1和非官方的cx_freeze 5.0构建可用from here。我正在尝试使用我一直在研究的tkintersympy来创建python项目的可执行版本。我使用cxfreeze-quickstart为程序创建了一个setup.py文件,并且在构建至少看似有效的可执行文件方面,它可以正常运行而不会丢失任何错误。但是,当我尝试运行可执行文件时,没有任何反应。我知道在这里已经提出了类似的问题,我已经看过并试图理解我发现的每一个问题,但没有一个解决方案对我有用。我不明白发生了什么,任何帮助将不胜感激。代码如下:

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)

提前致谢。

更新:我现在正在尝试根据文档中提供的模板自行编写setup.py脚本,尽管仍然会非常感谢任何帮助。

更新2:我根据文档中提供的模板编写了自己的setup.py,并将其放在与我想要冻结的脚本相同的文件夹中,这是我没有意识到我需要做的事情。我在命令行中运行python setup.py build,并使用exe和DLL创建了build子目录。但是,现在当我尝试运行exe时,会弹出一条错误消息,提示ImportError: DLL load failed. The specified module could not be found.引用tkinter。第二个setup.py的代码如下。

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)])

以下是physics2-0.py的前4行。错误消息引起的问题是第1行。

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

更新3:有人请帮帮我。我无法弄清楚这一点。我甚至在这一点上做了一个干净的重新安装python,只是为了确保我不会在某个时候意外搞砸了,而且它仍然给我同样的错误信息。

0 个答案:

没有答案