简体   繁体   English

exe错误与cx_freeze

[英]exe error with cx_freeze

Hey am relatively new to compiling python scripts to exe. 嘿,编译python脚本到exe是相对较新的。 Im using cx_freeze to compile my scripts and once its built i run the exe and it gives me this error. 我使用cx_freeze编译我的脚本,一旦它构建我运行exe,它给了我这个错误。 Have google around alot but not too sure. 谷歌周围很多但不太确定。 Error is: 错误是:

Cannot import traceback module.
Exception: No module named re
Original Exception: No module named re

Not too sure how to go about fixing this. 不太确定如何解决这个问题。 I read that possibly there is a clash between a module named re? 我读到可能在名为re的模块之间存在冲突? in python? 在python? and a module named re in cx_freeze module? 和一个名为re的模块在cx_freeze模块中?

My setup file looks like: 我的设置文件如下:

from cx_Freeze import setup, Executable

includes = []
includefiles = ['remindersText.pkl']
eggsacutibull = Executable(
    script = "podlancer.py",
    initScript = None,
    base = 'Win32GUI',
    targetName = "podlancer.exe",
    compress = True,
    copyDependentFiles = True,
    appendScriptToExe = False,
    appendScriptToLibrary = False,
    icon = None
    )

setup(
        name = "Podlancer",
        version = "0.1",
        author = 'jono',
        description = "Podlancer UI script",
        options = {"build_exe": {"includes":includes, "include_files": includefiles}},
        executables = [eggsacutibull]
        )

Try to change 试着改变

includes = []

to

includes = ["re"]

That worked for me 这对我有用

cx_freeze will barf if the runtime working directory is not the directory that the executable is in. 如果运行时工作目录不是可执行文件所在的目录,则cx_freeze将为barf。

Is re the first import you do? 你是第一次进口吗? What happens when you do them in a different order? 当你以不同的顺序执行时会发生什么?

Meeting this same problem putting re in includes didn't work for me. 遇到同样的问题将re includes并不适用于我。 It produced a cx_Freeze.freezer.ConfigError when rebuilding the .py file. 它在重建.py文件时产生了cx_Freeze.freezer.ConfigError

import sys
from cx_Freeze import setup, Executable

build_exe_options = {'include_files': ['re']}

setup(  name = "Foreground Window Montior",
        version = "0.1",
        description = "Query the foreground window.",
        options = {'build_exe': build_exe_options},
        executables = [Executable("actWin_Query.py")])

If I put re in packages rather than in include_files it did not produce this compile error. 如果我把re放在packages而不是include_files它就不会产生这个编译错误。

import sys
from cx_Freeze import setup, Executable

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

setup(  name = "Foreground Window Montior",
        version = "0.1",
        description = "Query the foreground window.",
        options = {'build_exe': build_exe_options},
        executables = [Executable("actWin_Query.py")])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM