【问题标题】:"UserWarning: Duplicate name"- when trying to make .exe with cx_Freeze“用户警告:名称重复”- 尝试使用 cx_Freeze 制作 .exe 时
【发布时间】:2017-04-07 03:42:32
【问题描述】:

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

设置:

  • Windows 7 企业版 64 位
  • WinPython-64bit-3.5.2.3Qt5(Python 3.5.2 64 位
  • cx_Freeze v. 4.3.4(winPython 自带)

要转换为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)

任何想法如何解决“重复名称” - 警告/错误?它生成一个可执行文件,但该可执行文件在运行时不执行任何操作。

【问题讨论】:

    标签: python windows python-3.5 cx-freeze


    【解决方案1】:

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

    【讨论】:

    • 在使用 cx_Freeze 5.0 构建期间没有错误,但我没有让示例工作,因为它使用的是 wxPython(但这将是一个新问题的主题)。
    猜你喜欢
    • 2012-11-07
    • 1970-01-01
    • 2016-09-22
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    相关资源
    最近更新 更多