Python cx_freeze安装脚本无法正常工作

时间:2014-10-19 18:38:22

标签: python python-3.x exe cx-freeze

我有一个我想要冻结的python脚本。我制作了cx_freeze脚本并运行它。 .exe效果很好,但在冻结的脚本中我打开了一个.html文件。当文件打开时,webbrowser会给我错误" File not found: Firefox cannot find the file at /c:/blah/blah/blah/somefile.html"

据我了解,这是因为cx_freeze使我的操作系统在Linux和Windows之间混乱。但是,我不确定是不是因为我有代码

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

在我的设置文件中。有谁知道发生了什么?

我的整个设置文件是

import sys
from cx_Freeze import setup, Executable

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

# 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 = "someexe",
    version = "0.1",
    description = "someexe description",
    options = {"build_exe": build_exe_options},
    executables = [Executable("someexe.py", base=base)])

the cx_freeze distutils page复制并编辑以满足我的需求。

1 个答案:

答案 0 :(得分:0)

您应该使用os.chdir('C:/path/to/dir'),而不是使用os.chdir('C:\path\to\dir')。这是您的脚本中的错误,而不是您的cx_freeze安装文件。

相关问题