You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Wine中用PyInstaller交叉编译Python至Windows时遇文件找不到错误

Wine下PyInstaller编译Python脚本的路径错误修复方案

直接修改PyInstaller脚本(临时修复)

找到报错的utils.py文件(对应Linux本地路径:/home/benedikt/Downloads/PyInstaller/depend/utils.py),定位到create_py3_base_library函数里的文件打开代码:
原代码:

with open(mod.filename, 'rb') as fs:

修改为:

# 修正Wine路径的斜杠问题
import os
# 替换Windows反斜杠为Linux正斜杠,同时去掉Z:前缀转成本地路径
corrected_path = mod.filename.replace('\\', '/').replace('Z:/', '/')
with open(corrected_path, 'rb') as fs:

保存后重新执行编译命令即可。

规避路径问题的替代方案

  • 解压python310.zip到Wine的Python安装目录(比如~/.wine/drive_c/python310/Lib),删除原zip包,让Python直接读取解压后的文件,绕开zip路径解析问题。
  • 把HALLOWELT.py复制到Wine的C盘目录(比如~/.wine/drive_c/users/benedikt/Desktop),用wine cmd切换到该目录后执行python -m PyInstaller HALLOWELT.py,避免跨Z盘的路径映射问题。

若需社区求助

整理以下信息后去PyInstaller官方issue区反馈:

  • 完整的错误回溯信息
  • Wine版本、Windows版Python版本、PyInstaller版本
  • 编译时的工作目录(Linux和Wine下的路径都要)
  • _collections_abc.pyc的实际Linux本地路径

内容的提问来源于stack exchange,提问作者ductTapeIsMagic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 21:33:23