首页 > 解决方案 > 如何解决 cx_freeze 错误:_ 和_ 是同一个文件?

问题描述

我试图将我的 pyqt5 应用程序转换为 exe。我正在使用 cx_freeze 这样做。我按照 cx_freeze 的要求创建了 setup.py 文件并运行python setup.py build命令来生成 exe。如图所示,在构建阶段似乎存在一些错误。显示错误:

creating directory build\exe.win-amd64-3.9\lib
copying data from package PyQt5...
copying Z:\translator\lib\site-packages\PyQt5\QtCore.pyd -> build\exe.win-amd64-3.9\lib\PyQt5\QtCore.pyd
copying C:\Users\Rishabh\AppData\Local\Programs\Python\Python39\python3.dll -> build\exe.win-amd64-3.9\lib\PyQt5\python3.dll
copying Z:\translator\lib\site-packages\PyQt5\Qt5\bin\Qt5Core.dll -> build\exe.win-amd64-3.9\lib\PyQt5\Qt5Core.dll
copying Z:\translator\lib\site-packages\PyQt5\QtGui.pyd -> build\exe.win-amd64-3.9\lib\PyQt5\QtGui.pyd
copying Z:\translator\lib\site-packages\PyQt5\Qt5\bin\Qt5Gui.dll -> build\exe.win-amd64-3.9\lib\PyQt5\Qt5Gui.dll
copying Z:\translator\lib\site-packages\PyQt5\QtWidgets.pyd -> build\exe.win-amd64-3.9\lib\PyQt5\QtWidgets.pyd
error: WindowsPath('Z:/translator/lib/site-packages/PyQt5/QtWidgets.pyd') and WindowsPath('build/exe.win-amd64-3.9/lib/PyQt5/QtWidgets.pyd') are the same file.

cx_freeze 从虚拟环境中复制 QtWidget.pyd 文件,然后引发两个文件相同的错误。这个问题怎么解决??

标签: pythonpyqt5cx-freeze

解决方案


卸载您首先运行的内容

然后检查文件WindowsPath('build/exe.win-amd64-3.9/lib/PyQt5/QtWidgets.pyd')路径中已经存在的完全相同。

我认为它可能存在于文件系统中 \src\Application\build/exe.win-amd64-3.9/lib/PyQt5/QtWidgets.pyd

如果存在,请删除该文件并重新安装


推荐阅读