Search code examples
pythonwindowspython-3.5cx-freeze

"UserWarning: Duplicate name"- when trying to make .exe with cx_Freeze


I'm trying to convert a python script to executable

Setup:

  • Windows 7 Enterprise 64-bit
  • WinPython-64bit-3.5.2.3Qt5 (Python 3.5.2 64-bit
  • cx_Freeze v. 4.3.4 (came with winPython)

File to be converted as exe:

matplotlib_eg.py (an example file), from WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\Lib\site-packages\cx_Freeze\samples\matplotlib.

Setup.py

(The original setup.py file with added os.environ['TCL_LIBRARY'] and os.environ['TK_LIBRARY'] lines)

import os
import sys
from cx_Freeze import setup, Executable


os.environ['TCL_LIBRARY'] = r"C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\tcl\tcl8.6" 
os.environ['TK_LIBRARY'] = r"C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\tcl\tk8.6" 


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

options = {
    'build_exe': {
        'excludes': ['Tkinter']  # Sometimes a little finetuning is needed
    }
}

executables = [
    Executable('matplotlib_eg.py', base=base)
]

setup(name='matplotlib_eg',
      version='0.1',
      description='Sample matplotlib script',
      executables=executables,
      options=options
      )

Problem

I get the following errors when running python setup.py build:

C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\cx_Freeze\freezer.py:590: UserWarning: Duplicate name: 'importlib/__init__.pyc'
  outFile.writestr(zinfo, data)
C:\WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\lib\site-packages\cx_Freeze\freezer.py:590: UserWarning: Duplicate name: 'statsmodels/__init__.pyc'
  outFile.writestr(zinfo, data)

Any ideas how to fix the "Duplicate name"-warning/error? It makes an executable but the executable does not do anything when ran.


Solution

  • You should use cx_Freeze 5.0 which supports Python 3.5 and was just released last week. The matplotlib example has been updated and confirmed to work in that release.