冻结应用程序后python中的“FileNotFoundError”

问题描述 投票:0回答:0

作为 python 应用程序的一部分,访问未映射的网络驱动器中的文件。该脚本在运行 .py 文件时运行起来非常棒,但是在使用 cx_freeze 将其冻结为 .exe 文件后,我收到以下错误:

FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\foo\bar\baz\file.txt'

运行以下行时:

sizelist = [float(Path(x).stat().st_size) for x in ListOfFiles]

文件肯定存在。我注意到在 Windows 的文件属性下,文件路径显示为:

\\?\UNC\foo\bar\baz\file.txt

此错误的原因是什么,您将如何解决?

我尝试使用 pathlib 和 os,并升级到 python 3.11(最新可用版本)。

python pathlib os.path
© www.soinside.com 2019 - 2024. All rights reserved.