#1276 ImportError: cannot import name 'genai' from 'google' (unknown location)

104.28* Posted at: 20 days ago 👁69

网络连接失败:Traceback (most recent call last):
File "/Volumes/NV3000 1TB Netac/Voice/pyvideotrans-3.82/videotrans/util/TestSrtTrans.py", line 19, in run

text:List[dict] = translator.run(translate_type=self.translator_type,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Volumes/NV3000 1TB Netac/Voice/pyvideotrans-3.82/videotrans/translator/__init__.py", line 919, in run

from videotrans.translator._gemini import Gemini

File "/Volumes/NV3000 1TB Netac/Voice/pyvideotrans-3.82/videotrans/translator/_gemini.py", line 20, in

from google import genai

ImportError: cannot import name 'genai' from 'google' (unknown location)


=
system:macOS-26.0.1-arm64-arm-64bit
version:v3.82
frozen:False
language:zh
root_dir:/Volumes/NV3000 1TB Netac/Voice/pyvideotrans-3.82
Python: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:54:21) [Clang 16.0.6 ]

1 Replies

这个错误是由于 Gemini 翻译所需的依赖包版本不兼容导致的。错误显示无法从 google 包中导入 genai 模块。

请按以下步骤解决:

  1. 更新依赖包:在终端中执行以下命令更新相关包:

    pip install --upgrade google-generativeai
    pip install --upgrade google-cloud-translate
  2. 检查安装路径:确保您的 Python 环境是干净的,没有多个版本的 google 包冲突。
  3. 临时解决方案:如果更新后问题依旧,可以暂时切换到其他翻译渠道,如 Google 翻译、Microsoft 翻译或 DeepSeek 等。

如果问题持续存在,请提供完整的日志文件(位于 videotrans/logs/ 目录下)以便进一步分析。

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

Trending Questions