#6124 程序内部错误:'str' object has no attribute 'get':Traceback (most recent call last): File

2401:f1e0* Posted at: 16 hours ago

程序内部错误:'str' object has no attribute 'get':Traceback (most recent call last):
File "videotrans\translator\_base.py", line 71, in run
File "videotrans\translator\_base.py", line 206, in _run_srt
File "tenacity\__init__.py", line 338, in wrapped_f
File "tenacity\__init__.py", line 477, in call
File "tenacity\__init__.py", line 378, in iter
File "tenacity\__init__.py", line 421, in exc_check
tenacity.RetryError: RetryError[]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "videotrans\util\TestSrtTrans.py", line 19, in run
File "videotrans\translator\_runner.py", line 63, in run
File "videotrans\translator\_base.py", line 74, in run
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 82, in _item_task
AttributeError: 'str' object has no attribute 'get'


=
system:Windows-10-10.0.26200-SP0
version:v4.07
frozen:True
language:zh
root_dir:D:/win-pyvideotrans-v4.05-0711

3 Replies

这是由于翻译渠道返回的数据格式异常导致的:代码期望收到一个字典(带 .get() 方法),但实际收到了一个字符串,常见于使用兼容 OpenAI 接口的翻译渠道(如 DeepSeek、OpenAI、LocalLLM 等)配置不当或返回数据不符合预期。

请按以下步骤排查:

  1. 确认翻译渠道及配置:当前使用了哪个翻译渠道?如果是 兼容 AI/本地模型DeepSeekOpenAI ChatGPT 等,请检查:

    • API 地址是否正确(本地服务地址不能是 0.0.0.0,应改为 http://127.0.0.1:端口
    • 模型名称是否填写正确(例如 deepseek-v4-flashgpt-4.1 等,不能留空或填错)
    • API 密钥是否有效、余额是否充足
  2. 临时切换渠道测试:将翻译渠道改为免费的 微软翻译Google 翻译,重新执行一次,若正常则说明问题出在原来的 AI 渠道上。
  3. 检查高级选项中的相关设置

    • 打开 菜单 → 工具 → 高级选项 → 字幕翻译调整
    • 确认 AI翻译渠道每批字幕行数 设为合理值(例如 50~100),不要设为 0
    • 如果使用了 发送完整字幕,请确认对应模型能正确处理带时间轴的 SRT 格式(可临时取消勾选测试)
  4. 检查自定义提示词:如果修改过 videotrans/prompts/srt/text/ 中的提示词,请恢复为默认内容,避免格式语法错误导致模型返回异常。
  5. 清理翻译缓存:删除 软件目录/tmp/translate_cache/ 下的所有文件,防止缓存了异常结果。

如果以上排查后问题仍然存在,请提供以下信息以便进一步分析:

  • 翻译渠道的具体名称(例如 DeepSeek / OpenAI / 兼容AI本地模型)
  • 该渠道设置界面中填写的 API 地址和模型名称
  • logs/ 目录下最新日志文件(复制最后 30 行左右的完整错误堆栈)

请查阅相关文档:

我用的本地大模型 ollma

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.

Dondate via ko-fi.com

Dondate via PayPal

Related resource