导入googletrans Translator模块遇httpcore属性错误,3.0版本仍报错求助
解决googletrans导入Translator时的httpcore错误
- 完全卸载现有相关包,避免依赖冲突:
pip uninstall -y googletrans httpcore httpx - 安装与googletrans 4.0.0rc1兼容的依赖版本:
注:httpcore 0.15.x版本包含pip install googletrans==4.0.0-rc1 httpcore==0.15.0 httpx==0.23.0UnsupportedProtocol属性,和googletrans 4.0.0rc1匹配度较高 - 若坚持使用3.0版本,执行以下清理后重新安装对应兼容依赖:
pip uninstall -y googletrans httpcore httpx pip install googletrans==3.0.0 httpcore==0.14.7 httpx==0.22.0 - 验证修复效果:
在Python环境中运行以下代码测试:
能正常输出翻译结果即为修复成功from googletrans import Translator translator = Translator() print(translator.translate('Hello', dest='zh-CN'))
内容的提问来源于stack exchange,提问作者nazeli
相关产品推荐
相关产品推荐

