#980 AttributeError: module 'videotrans.util.tools' has no attribute 'get_edge_rolelist'

8.219* Posted at: 1 day ago 👁11

Traceback (most recent call last):

File "/Users/user/Downloads/pyvideotrans-main/videotrans/mainwin/_actions.py", line 479, in set_voice_role

show_rolelist = tools.get_edge_rolelist()

File "/Users/user/Downloads/pyvideotrans-main/videotrans/util/tools.py", line 61, in __getattr__

raise AttributeError(f"module '{__name__}' has no attribute '{name}'")

AttributeError: module 'videotrans.util.tools' has no attribute 'get_edge_rolelist'

=====

macOS-15.0.1-arm64-arm-64bit

version:v3.81

frozen:False

language:zh

1 Replies

本条内容由 gpt-5-mini 回复
很可能原因:代码在调用 videotrans.util.tools.get_edge_rolelist() 时该函数在当前源码中不存在(被重命名、被移除或源码不完整),导致 AttributeError。解决思路:确认源码中是否存在该函数、修复调用或恢复正确的版本。请按下列步骤排查和修复:

1. 快速定位函数是否存在(在项目根目录执行):

  • grep -n "get_edge_rolelist" -R .
  • 如果没有结果,再试查找类似名字:
  • grep -n "edge_role" -R .

这些命令能判断是函数缺失还是被改名。

2. 列出 tools 模块中实际可用的属性(在项目根目录的 Python 环境中运行):

  • python -c "import videotrans.util.tools as t; print([x for x in dir(t) if not x.startswith('_')])"

通过该命令可以看到可调用的函数名,便于确认应调用哪个函数。

3. 检查具体调用点并临时修复:

  • 打开报错处文件 videotrans/mainwin/_actions.py 第479行,查看调用代码;如果找到相近的正确函数名(例如 get_edge_role_list 或 get_edge_roles 等),可以临时将 get_edge_rolelist 改为项目中实际存在的函数名并重启程序测试。
  • 如果不确定替换哪个函数,先不要随意修改代码,改为下面的“恢复/替换源码”步骤。

4. 恢复或更新源码(推荐,防止本地改动导致其他问题):

  • 如果是从 Git 克隆的仓库:git fetch && git checkout v3.81 或 git pull origin main(根据你使用的分支/Tag)以确保源码完整且为官方版本。
  • 如果是手动下载的压缩包,建议重新从官方发布页或 GitHub release 下载 v3.81 源码包并解压覆盖当前目录(记得备份本地改动)。

5. 临时绕过(如果只想继续使用 TTS):

  • 在 GUI 的 TTS 设置中手动选择/填写你需要的声音角色(菜单 -> TTS 配音设置),或直接在 videotrans/params.json 中手动设置相关 TTS 配置(params.json 保存了 TTS/识别/翻译的密钥与具体选项),以避免程序在取得角色列表时触发该错误。

6. 如果以上步骤无法定位原因,请提供以下信息以便进一步诊断:

  • videotrans/logs/ 目录下最新的日志文件(最近一次运行时生成的 {年月日}.log)。
  • 文件 videotrans/util/tools.py 的完整内容。
  • 文件 videotrans/mainwin/_actions.py 从第440行到第520行的代码片段(包含报错位置附近)。
  • grep -n "get_edge_rolelist" -R . 的输出(如果有的话)。

根据现有信息和官方文档,我无法确定具体原因,请提供上面列出的日志和源码片段以便进一步分析。

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Donate: https://ko-fi.com/jianchang512

Similar issues already exist

Trending Questions