Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exe error with cx_freeze

Hey am relatively new to compiling python scripts to exe. Im using cx_freeze to compile my scripts and once its built i run the exe and it gives me this error. 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? in python? and a module named re in cx_freeze module?

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]
        )
like image 245
Mafster Avatar asked Apr 09 '11 06:04

Mafster


People also ask

What is cx_Freeze?

cx_Freeze is a set of scripts and modules for freezing Python scripts into executables, in much the same way that py2exe and py2app do. Unlike these two tools, cx_Freeze is cross-platform and should work on any platform that Python itself works on. It supports Python 2.7 or higher (including Python 3).

What is cx_ Freeze python error in main script?

According to some Windows users' reports, the problem “cx_Freeze: Python error in main script” may be caused by a poorly written Phyton application like PlayTV or Raptr. If you are in this case, you can try to uninstall PlayTV or Raptr to fix the cx_Freeze Python error. There are two ways to uninstall applications.


2 Answers

Try to change

includes = []

to

includes = ["re"]

That worked for me

like image 67
Azimkhan Avatar answered Sep 18 '22 00:09

Azimkhan


cx_freeze will barf if the runtime working directory is not the directory that the executable is in.

Is re the first import you do? What happens when you do them in a different order?

like image 31
Nick ODell Avatar answered Sep 21 '22 00:09

Nick ODell