0

I am trying to build an .exe file of my Python application. I have tried various ways to create a setup file from both Github and Stackoverflow and I keep getting this same error:

pywintypes.error: (2, 'BeginUpdateResource', 'The system cannot find the file specified.').

I am using Python 3.6.1, and cx_Freeze to build the application.

Here are the different setup files I have tried:

Attempt 1:

import os.path
from cx_Freeze import setup, Executable  

os.environ['TCL_LIBRARY'] = r'C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6'

executables = [Executable("myprogram.py", base="Win32GUI")]

options = {
    'build_exe': {

        'include_files': [
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
            os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),

        ]
    },

}

setup(
    name="Standalone.exe",
    options=options,
    version="0.1",
    description='Simple tkinter application',
    executables=executables, requires=['cx_Freeze', 'cx_Freeze']
)

Attempt 2:

from cx_Freeze import setup, Executable
import sys
import os

productName = "My Program"
if 'bdist_msi' in sys.argv:
    sys.argv += ['--initial-target-dir', r'C:\Users\RedCode\PycharmProjects\Standalone' + productName]
    sys.argv += ['--install-script', 'myprogram.py']

os.environ['TCL_LIBRARY'] = r'C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6'

exe = Executable(
      script="myprogram.py",
      base="Win32GUI",
      targetName="Product.exe"
     )
setup(
      name="Standalone.exe",
      version="1.0",
      author="Me",
      description="Copyright 2012",
      executables=[exe],
      scripts=[
               'myprogram.py'
               ]
      )

Attempt 3:

import sys
import os
from cx_Freeze import setup, Executable


build_exe_options = {"packages": ["os"], "includes": ["tkinter"]}


def s_SourceFile():
    if (sys.argv[0] == ''):
        return __file__
    else:
        return sys.argv[0]


os.environ['TCL_LIBRARY'] = r'C:\Users\stefano.demattia\AppData\Local\Programs\Python\Python36-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\stefano.demattia\AppData\Local\Programs\Python\Python36-32\tcl\tk8.6'

setup(name="Standalone",
      version="0.1",
      description="My GUI application!",
      options={"build_exe": build_exe_options},
      executables=[Executable("myprogram.py", base="Win32GUI", targetName="Standalone.exe")])

Attempt 4:

application_title = "Car Database"
main_python_file = "cardb.py"

import sys

from cx_Freeze import setup, Executable

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

setup(
        name = "myprogram.py",
        version = "0.1",
        description = "Simple embedded database application",
        executables = [Executable("myprogram.py", base = base)])

I have also tried pyinstaller but it keeps giving me a tuple out of range error no matter what I do, and I tried bbfreeze which I can't even get to install. I have checked my files and everything is there, so I do not see how it can still tell me a specified file is not found.

What else can I do or how can I edit the above attempts so that the application actually builds properly? Is there even a way to determine which file is missing?

RedCode
  • 363
  • 1
  • 6
  • 23
  • is that error during the freezing or when you try to run the frozen application? either way please post the full error message. – Gardener85 May 31 '17 at 15:52
  • 1
    I don't run this from python terminal. I just open a regular command prompt. then I do a 'cd' to the direction my .py file is stored. So for example I would do 'cd C:\Users\gardener\PycharmProjects\untitled5\' Then I would type 'python setup.py build' – Gardener85 Jun 01 '17 at 17:37

2 Answers2

1

Remove the version, I got the same error, looked at the code and noticed it was referencing versioning in the source, so thought I'd try it, and it fixed it for me.

I know the poster probably no longer needs this, but posting it for others that come across this in the future since I didn't see the answer anywhere else.

emlay
  • 11
  • 1
  • Hi, your answer might be a bit more helpful if you could add the statement with the version removed in case that's not clear to the OP. – Anurag A S May 09 '21 at 06:15
0
cx_Freeze.setup(
name="SampleName",
options={"build_exe": {"packages": ["tkinter", "os"],
                       "include_files": ['tcl86t.dll', 'tk86t.dll', 'closenew.png', 'sujata.png', 'config.py', 'ui_attributes.py']}},
version="0.01", # Remove this line
description="Tkinter Application",
executables=executables
)

I have removed the version and it worked.

cx_Freeze.setup(
name="SampleName",
options={"build_exe": {"packages": ["tkinter", "os"],
                       "include_files": ['tcl86t.dll', 'tk86t.dll', 'closenew.png', 'sujata.png', 'config.py', 'ui_attributes.py']}},
description="Tkinter Application",
executables=executables
)
m4n0
  • 29,823
  • 27
  • 76
  • 89