bug
This commit is contained in:
1 parent
53877e254f
commit
3c4881c0e9
2 files changed
+27
-8
No files matched your search
@@ -57,9 +57,12 @@ factory_sliceing.exe begin_sliceing C:\work\data
|
||||
|
||||
1. **依赖项**: 确保所有依赖已安装(redis, oss2, requests, uiautomation, pywin32 等)
|
||||
2. **隐藏导入**: 打包脚本已自动包含常见模块(uiautomation, win32gui 等),如果运行时仍提示模块未找到,可以在 `build_exe.py` 中添加 `--hidden-import` 参数
|
||||
3. **数据文件**: 如果项目需要配置文件或其他数据文件,需要添加 `--add-data` 参数
|
||||
3. **数据文件**:
|
||||
- `small_machine_transform.py` 已自动包含在打包脚本中(作为数据文件)
|
||||
- 如果项目需要其他配置文件或数据文件,需要添加 `--add-data` 参数
|
||||
4. **文件大小**: 打包后的 exe 文件可能较大(通常 50-200MB),这是正常的,因为包含了 Python 解释器和所有依赖
|
||||
5. **uiautomation**: 已自动包含在打包脚本中,使用 `--collect-all=uiautomation` 确保完整打包
|
||||
6. **small_machine_transform.py**: 已自动包含在打包脚本中,会被 Blender 作为外部脚本调用
|
||||
|
||||
## 故障排除
|
||||
|
||||
@@ -84,3 +87,8 @@ factory_sliceing.exe begin_sliceing C:\work\data
|
||||
- 这是正常的,PyInstaller 会打包 Python 解释器和所有依赖
|
||||
- 可以使用 `--exclude-module` 排除不需要的模块来减小体积
|
||||
|
||||
### 问题:转换脚本文件不存在(small_machine_transform.py)
|
||||
- **已修复**: `small_machine_transform.py` 已自动包含在打包脚本中
|
||||
- 如果仍然提示文件不存在,检查 `build_exe.py` 中的 `--add-data` 参数是否正确
|
||||
- 文件会被放在 `_MEIPASS/utils/` 和 `_MEIPASS/download_batch_data/utils/` 目录下
|
||||
|
||||
@@ -74,17 +74,28 @@ def build_exe():
|
||||
# 收集 uiautomation 的所有子模块(确保完整打包)
|
||||
'--collect-all=uiautomation',
|
||||
|
||||
# 添加数据文件(如果需要)
|
||||
# '--add-data=config;config', # Windows 格式
|
||||
# '--add-data=config:config', # Linux/Mac 格式
|
||||
|
||||
# 工作目录设置
|
||||
# 添加数据文件
|
||||
# small_machine_transform.py 需要作为数据文件包含,因为它会被 Blender 作为外部脚本调用
|
||||
# 注意:PyInstaller 会将数据文件放在 _MEIPASS 目录下
|
||||
]
|
||||
|
||||
# 添加 small_machine_transform.py 数据文件
|
||||
small_transform_file = os.path.join(current_dir, "download_batch_data", "utils", "small_machine_transform.py")
|
||||
if os.path.exists(small_transform_file):
|
||||
# Windows 使用分号,Linux/Mac 使用冒号
|
||||
path_sep = ';' if sys.platform == 'win32' else ':'
|
||||
# 添加到 utils/ 目录(get_resource_path('utils/small_machine_transform.py') 会查找这里)
|
||||
cmd.append(f'--add-data={small_transform_file}{path_sep}utils')
|
||||
# 也添加到 download_batch_data/utils/ 目录(备用路径)
|
||||
cmd.append(f'--add-data={small_transform_file}{path_sep}download_batch_data/utils')
|
||||
|
||||
# 添加工作目录设置和主脚本
|
||||
cmd.extend([
|
||||
f'--workpath={os.path.join(current_dir, "build")}',
|
||||
f'--distpath={os.path.join(current_dir, "dist")}',
|
||||
f'--specpath={os.path.join(current_dir, "build")}',
|
||||
|
||||
main_script
|
||||
]
|
||||
])
|
||||
|
||||
print("=" * 60)
|
||||
print("开始打包 factory_sliceing 项目...")
|
||||
|
||||
Reference in new issue
Block a user