As a part of a python application, files in unmapped network drive are accessed. The script runs like a charm when running the .py file, but after freezing it as an .exe file using cx_freeze I am getting the following error:
FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\foo\bar\baz\file.txt'
When running the following line:
sizelist = [float(Path(x).stat().st_size) for x in ListOfFiles]
The file definitely exists. I have noticed that under file properties in Windows, the file path is shown as:
\\?\UNC\foo\bar\baz\file.txt
What is the reason for this error and how would you fix it?
I have tried working with pathlib and os, and upgrading to python 3.11 (latest available version).
EDIT: I have isolated the issue as caused by cx_Freeze. I have frozen the following script in cx_Freeze and pyinstaller:
# encoding: utf-8
from pathlib import Path
folder = input("Folder:")
file_list = []
file_list += list(Path(folder).rglob("**/*.mdf"))
file_list += list(Path(folder).rglob("**/*.mf4"))
file_list += list(Path(folder).rglob("**/*.dat"))
print([(Path(p), Path(p).is_file()) for p in file_list]) # For tracking
x = input("Press enter...")
When frozen with pyinstaller, Path(p).is_file() is True for all files. With cx_Freeze, the behavious is the same as previously described.
Is it there a way to solve this issue on cx_Freeze?