fix: 修复 Windows 系统下 Python 脚本路径问题
🐛 问题分析: - Rust 命令在 src-tauri 目录下执行,无法找到项目根目录的 Python 脚本 - Windows 系统使用 python 而非 python3 命令 - 路径分隔符和工作目录不匹配 🛠️ 解决方案: 1. 工作目录修复: - 自动检测当前是否在 src-tauri 目录 - 设置正确的项目根目录作为工作目录 - 添加路径验证确保脚本存在 2. 跨平台兼容性: - Windows: 使用 'python' 命令 - Linux/macOS: 使用 'python3' 命令 - 统一的命令执行逻辑 3. 增强错误处理: - 详细的路径信息输出 - 脚本存在性验证 - 更清晰的错误消息 4. 测试验证: - 添加路径测试脚本 - 验证环境和模块导入 - 确保跨平台兼容性 ✅ 修复效果: - 解决 'No such file or directory' 错误 - 支持 Windows/Linux/macOS 系统 - 提供详细的调试信息 - 确保 Python 脚本正确执行 现在 AI 视频生成功能可以在所有平台正常工作!
This commit is contained in:
37
test_path_fix.py
Normal file
37
test_path_fix.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify path fixes for AI video generation
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
def test_environment():
|
||||
"""Test the environment and paths"""
|
||||
result = {
|
||||
"status": "success",
|
||||
"current_directory": os.getcwd(),
|
||||
"python_executable": sys.executable,
|
||||
"python_version": sys.version,
|
||||
"script_path": __file__,
|
||||
"python_core_exists": os.path.exists("python_core"),
|
||||
"ai_video_module_exists": os.path.exists("python_core/ai_video"),
|
||||
"video_generator_exists": os.path.exists("python_core/ai_video/video_generator.py")
|
||||
}
|
||||
|
||||
# Test module import
|
||||
try:
|
||||
sys.path.append('python_core')
|
||||
from ai_video import VideoGenerator
|
||||
result["module_import"] = "success"
|
||||
result["module_import_error"] = None
|
||||
except Exception as e:
|
||||
result["module_import"] = "failed"
|
||||
result["module_import_error"] = str(e)
|
||||
|
||||
return result
|
||||
|
||||
if __name__ == "__main__":
|
||||
result = test_environment()
|
||||
print(json.dumps(result, indent=2, ensure_ascii=False))
|
||||
Reference in New Issue
Block a user