Search code examples
pythonwindows-installercx-freeze

Why dose cx_freeze throw the exception like 'MSIError'


I met the question about making .py into .exe. When I try using cx_freeze to pack, I will always get 'MSIError', which is something like this:

Traceback (most recent call last):
File "setup.py", line 15, in <module>
  setup(name="NumberCounter",version="1.0",description="无",options={"build_exe":build_options},executables=executables)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
  distutils.core.setup(**attrs)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\distutils\core.py", line 148, in setup
  dist.run_commands()
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 955, in run_commands
  self.run_command(cmd)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_command
  cmd_obj.run()
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\site-packages\cx_Freeze\windist.py", line 392, in run
  self.add_files()
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\site-packages\cx_Freeze\windist.py", line 133, in add_files
  cab.commit(db)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\msilib\__init__.py", line 220, in commit
  add_stream(db, self.name, filename)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\msilib\__init__.py", line 129, in add_stream
  r.SetStream(1, path)
_msi.MSIError: 1: 1101 2: C:\Users\apple1\AppData\Local\Temp\tmp5kgryuh8 3: 2

How can I solve it and why did it happen?


Solution

  • I'll unpack the error line for you.

    _msi.MSIError: 1: 1101 2: C:\Users\apple1\AppData\Local\Temp\tmp5kgryuh8 3: 2
    
    • Per Windows Installer Error Messages, 1101 means Could not open file stream: [2]. System error: [3].

    • Per command net helpmsg 2, system error 2 is The system cannot find the file specified.

    The path appears to be a temporary file that should have been created, but according to the error, it probably was not. You could try to use a tool like Process Monitor to figure out what if anything is going on with the temporary files.

    I don't know anything useful about cx_freeze, but I do know that Windows Installer's support for Unicode is a little surprising; it can easily come off as half-baked. Because of that, I would worry about your description="无", and consider setting that to a simple ASCII-only string, just to see if it helps.