【问题标题】:pyinstaller + PySide6 -- WARNING: file already exists but should not:pyinstaller + PySide6 -- 警告:文件已经存在但不应该:
【发布时间】:2021-12-15 19:49:13
【问题描述】:

当我编译我的应用程序时,我遇到了与 here 描述的类似问题

我的警告如下所示:

[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtCore.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtGui.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtNetwork.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtOpenGL.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtPrintSupport.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtQml.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtQuick.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtWebEngineCore.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtWebEngineWidgets.pyd
[18136] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI181362\PySide6\QtWidgets.pyd

受其他帖子回答的启发,我在我的规范文件中添加了以下代码:

to_remove = ["QtCore.pyd", "QtGui.pyd", "QtNetwork.pyd", 
             "QtOpenGL.pyd","QtPrintSupport.pyd", "QtQml.pyd", \
             "QtQuick.pyd", "QtWebEngineCore.pyd","QtWebEngineWidgets.pyd", \
             "QtWidgets", "QtOpenGL.pyd"]

to_remove_alt = ["PySide6.QtQuick", "PySide6.QtNetwork", "PySide6.QtPrintSupport", 
                 "PySide6.QtCore", "PySide6.QtWebEngineWidgets", \
                 "PySide6.QtQml", "PySide6.QtGui", "PySide6.QtWidgets", 
                 "PySide6.QtOpenGL", 
                 "PySide6.QtWebEngineCore", "PySide6.QtNetwork"]



for b in a.binaries:
      if str(b[1]).rsplit("\\",1)[1] not in to_remove:
          pass
      else:
          print("removed " + b[1])
          a.binaries.remove(b)

    
for b in a.binaries:
      if b[0] not in to_remove_alt:
          pass
      else:
          print("removed " + b[0])
          a.binaries.remove(b)

哪个输出

removed c:\digikwondo\project\venv\lib\site-packages\PySide6\QtQuick.pyd
removed c:\digikwondo\project\venv\lib\site-packages\PySide6\QtOpenGL.pyd
removed c:\digikwondo\project\venv\lib\site-packages\PySide6\QtPrintSupport.pyd
removed c:\digikwondo\project\venv\lib\site-packages\PySide6\QtCore.pyd
removed c:\digikwondo\project\venv\lib\site-packages\PySide6\QtWebEngineWidgets.pyd
removed PySide6.QtNetwork
removed PySide6.QtGui
removed PySide6.QtWidgets

现在当我启动应用程序时,我仍然会收到这些警告

[1772] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI17722\PySide6\QtQml.pyd
[1772] WARNING: file already exists but should not: 
C:\Users\digikwondo\AppData\Local\Temp\_MEI17722\PySide6\QtWebEngineCore.pyd

为什么最后两个文件(QtQml.pyd, QtWebEngineCore.pyd) 没有被删除? (尽管在我的列表中)

我错过了什么吗?

我的平台:

PyInstaller: 4.5.1
Python: 3.9.2
Platform: Windows-10-10.0.19041-SP0

安装的包

Package                   Version
------------------------- ---------
altgraph                  0.17.2
auto-py-to-exe            2.10.1
bottle                    0.12.19
bottle-websocket          0.2.9
certifi                   2021.10.8
cffi                      1.15.0
charset-normalizer        2.0.7
cycler                    0.10.0
docopt                    0.6.2
Eel                       0.12.4
future                    0.18.2
gevent                    21.8.0
gevent-websocket          0.10.1
greenlet                  1.1.2
gunicorn                  20.1.0
idna                      3.3
Jinja2                    3.0.2
json2html                 1.3.0
kiwisolver                1.3.2
MarkupSafe                2.0.1
matplotlib                3.4.3
matplotlibqml             0.92.2
numpy                     1.21.3
pandas                    1.3.4
pefile                    2021.9.3
Pillow                    8.4.0
pip                       21.3.1
psutil                    5.8.0
pycparser                 2.20
pycryptodomex             3.11.0
pyinstaller               4.5.1
pyinstaller-hooks-contrib 2021.3
pyparsing                 3.0.1
pypiwin32                 223
PySide6                   6.2.0
python-dateutil           2.8.2
pytz                      2021.3
pywin32                   302
pywin32-ctypes            0.2.0
pyzipper                  0.3.5
requests                  2.26.0
setuptools                57.0.0
shiboken6                 6.2.0
six                       1.16.0
tinyaes                   1.0.1
tornado                   6.1
urllib3                   1.26.7
wheel                     0.36.2
whichcraft                0.6.1
yarg                      0.1.9
zope.event                4.5.0
zope.interface            5.4.0

【问题讨论】:

    标签: python-3.x pyinstaller pyside6


    【解决方案1】:

    经过大量的跟踪和错误,spec 文件中的以下代码似乎已经成功了!

    to_rem = ["PySide6.QtQuick", "PySide6.QtNetwork", "PySide6.QtPrintSupport", 
              "PySide6.QtCore", "PySide6.QtWebEngineWidgets", \
              "PySide6.QtQml", "PySide6.QtGui", "PySide6.QtWidgets", 
              "PySide6.QtOpenGL", "PySide6.QtWebEngineCore", 
              "PySide6.QtNetwork"]
          
    
    for val in to_rem:
        for b in a.binaries:
              nb = b[0]
              if str(nb).endswith(val):
                    print("removed  " + b[0])
                    a.binaries.remove(b)
    

    现在我的应用启动并运行良好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-28
      • 2018-02-21
      • 1970-01-01
      • 1970-01-01
      • 2013-12-08
      • 2015-07-23
      • 1970-01-01
      • 2017-11-23
      相关资源
      最近更新 更多