"UserWarning: Duplicate name"- 尝试使用 cx_Freeze 制作 .exe 时

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

我正在尝试将 python 脚本转换为可执行文件

设置:

要转换为 exe 的文件:

matplotlib_eg.py(示例文件),来自 WinPython-64bit-3.5.2.3Qt5\python-3.5.2.amd64\Lib\site-packages\cx_Freeze\samples\matplotlib.

Setup.py

(添加了 os.environ['TCL_LIBRARY'] 和 os.environ['TK_LIBRARY'] 行的原始 setup.py 文件)

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
      )

问题

当 运行 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)

关于如何修复 "Duplicate name"-warning/error 有什么想法吗?它生成一个可执行文件,但在 运行 时该可执行文件不执行任何操作。

你应该使用 cx_Freeze 5.0,它支持 Python 3.5,上周刚刚发布。 matplotlib 示例已更新并确认可在该版本中使用。