'Pyinstaller --onefile warning file already exists but should not
When running Pyinstaller --onefile
, and starting the resulting .exe
, multiple popups show up with the following warning:
WARNING: file already exists but should not: C:\Users\myuser\AppData\Local\Temp\_MEI90082\Cipher\_AES.cp37-win_amd64.pyd
This makes the .exe
hard to use even though clicking through the warnings still allows the .exe
to run properly.
How to get rid of these warnings ?
Solution 1:[1]
Going to put this here in case it helps anyone, since I spent some time finding out how to do this.
in the .spec
of your pyinstaller project, add this after the line a = Analysis(...)
:
# Avoid warning
to_remove = ["_AES", "_ARC4", "_DES", "_DES3", "_SHA256", "_counter"]
for b in a.binaries:
found = any(
f'{crypto}.cp37-win_amd64.pyd' in b[1]
for crypto in to_remove
)
if found:
print(f"Removing {b[1]}")
a.binaries.remove(b)
Of course you may adapt the array to_remove
as well as the exact file name .cp37-win_amd64.pyd
to match the files that show up in your warnings.
This results in the files not being included in the .exe
and the warnings are gone.
Solution 2:[2]
I have almost the same issue.
Not a good idea - remove part of the list that you are iterating.
Try this:
from PyInstaller.building.datastruct import TOC
# ...
# a = Analysis(...)
x = 'cp36-win_amd64'
datas_upd = TOC()
for d in a.datas:
if x not in d[0] and x not in d[1]:
datas_upd.append(d)
a.datas = datas_upd
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mananony |
Solution 2 | cnstntn.kndrtv |