news 2026/4/18 7:38:40

本地部署 libretranslate

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
本地部署 libretranslate

Window本地部署 libretranslate

目录

Libretranslate

网址

安装

安装问题

解决方案

步骤 1

步骤 2

步骤 3

提示错误

解决步骤

步骤 1

步骤 2

步骤 3

问题

安装libretranslate提示

启动

本地访问

请求失败

总结


Libretranslate

LibreTranslate 是一款开源、免费且支持自托管的机器翻译引擎,其核心优势在于‌完全不依赖谷歌、百度、微软等第三方在线翻译服务‌,所有翻译计算均可在本地设备(如电脑、服务器、NAS甚至树莓派)上完成,确保数据隐私与安全。‌

网址

https://docs.libretranslate.com/guides/installation/

安装

使用Python

请确保已安装 Python >= 3.8,然后从终端运行:

pip install libretranslate libretranslate [args]

安装问题

安装libretranslate时提示错误:

解决方案

步骤 1

先按提示升级 pip(必做,旧版 pip 是主要诱因)

直接在命令行执行提示里的升级命令,以管理员身份运行 CMD/PowerShell 执行更稳妥(避免权限不足):

python.exe -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
步骤 2

安装 Python 包编译所需的基础构建依赖(Windows 必装)

LibreTranslate 的部分依赖包需要本地编译,Windows 默认没有 C++ 编译工具和 Python 构建组件,会直接导致「构建依赖安装失败」,先安装基础构建包:

pip install wheel setuptools build -i https://pypi.tuna.tsinghua.edu.cn/simple
步骤3

用国内镜像源安装 LibreTranslate(避免网络下载中断)

完成以上环境准备后,用清华 / 阿里镜像源安装 LibreTranslate,彻底解决官方源下载慢、断连导致的依赖安装失败,执行命令:

pip install libretranslate -i https://pypi.tuna.tsinghua.edu.cn/simple
提示错误

note: This error originates from a subprocess, and is likely not a problem with pip.

ERROR: Failed to build 'spacy' when installing build dependencies for spacy

若没装过基础构建包,先补装:

pip install wheel setuptools build cmake -i https://pypi.tuna.tsinghua.edu.cn/simple
解决步骤
步骤 1

安装 Windows 预编译版spacy(指定稳定版,避免兼容问题)

用国内源安装spacy最新稳定版(3.7.x,与 LibreTranslate 完美兼容),pip 会自动匹配 Windows 的预编译包:

pip install spacy==3.7.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
步骤 2

安装spacy轻量语言模型(LibreTranslate 必需,否则启动报错)

spacy运行必须搭配语言模型,LibreTranslate 依赖其基础模型做文本处理,装轻量版即可(体积小、安装快),执行专用命令下载:

# 安装英文轻量模型(LibreTranslate核心依赖),自动适配已装的spacy版本

python -m spacy download en_core_web_sm -i https://pypi.tuna.tsinghua.edu.cn/simple
步骤 3

正式安装 LibreTranslate(此时无构建报错)

spacy和基础环境都到位后,再装 LibreTranslate,pip 会直接使用已安装的依赖,不会再触发任何构建操作:

pip install libretranslate -i https://pypi.tuna.tsinghua.edu.cn/simple
问题

步骤2 requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(10060, '由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。', None, 10060, None)) 需要更换为国外网络后,重新执行步骤2

安装libretranslate提示

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.

build 1.4.0 requires packaging>=24.0, but you have packaging 23.1 which is incompatible.

torchvision 0.12.0+cu113 requires torch==1.11.0, but you have torch 2.4.0 which is incompatible.

wheel 0.46.3 requires packaging>=24.0, but you have packaging 23.1 which is incompatible.

这些是pip 依赖冲突警告,并非安装失败的错误

升级 packaging 到兼容版本

python.exe -m pip install packaging==24.1 -U -i https://pypi.tuna.tsinghua.edu.cn/simple

这个结果是完全正常的!你已经成功把packaging升级到了24.1 这个唯一的兼容版,屏幕上的只是 pip 的版本检查警告,不是安装失败的错误,最后一行Successfully installed packaging-24.1才是关键 —— 代表环境已经调整到位,所有依赖的兼容问题都解决了。

启动

Libretranslate

运行效果:

然后打开网页浏览器以 http://localhost:5000

默认情况下,LibreTranslate 将为所有可用语言安装支持。只需加载某些语言并缩短启动时间,您就可以使用--load-only:

libretranslate --load-only en,es,fr

本地访问

http://127.0.0.1:5000/?source=auto&target=ko&q=%E4%B8%AD%E6%96%87

中文翻译为韩语

请求失败

窗口提示

requests.exceptions.ConnectionError: HTTPSConnectionPool (host='huggingface.co', port=443): Max retries exceeded with url: /stanfordnlp/stanza-zh-hans/resolve/v1.10.0/models/tokenize/gsdsimp.pt (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000211205A1340>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。'))

发现不是真正的本地翻译,还需要请求远程,需要使用国外网络才能使用翻译。

总结

Window本地部署 libretranslate不太适合国内项目使用,使用Api需要购买密钥,至于托管还没有研究怎么使用。

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/16 16:14:16

ClickHouse Exit Code 139 / SIGSEGV 排查手册与原理说明

这里写目录标题 ClickHouse Exit Code 139 / SIGSEGV 排查手册与原理说明1. 现象总览2. 基础原理说明2.1 什么是 Exit Code 1392.2 ClickHouse 为什么会 SIGSEGV 3. 日志特征与关键判断点3.1 典型 Fatal 日志结构3.2 常见 Crash Stack 特征&#xff08;示例&#xff09; 4. 与 …

作者头像 李华
网站建设 2026/4/18 5:32:34

掌握Prompt与Context协同,轻松打造高精准AI Agent(收藏版)

当前 AI 应用开发领域&#xff0c;不少开发者陷入 “唯模型论” 误区 —— 认为只要选用顶尖大模型&#xff0c;就能打造出高适配的 AI Agent。但实际落地中&#xff0c;大量应用因 “指令模糊”“信息缺失” 导致 AI 回复偏离用户需求。本质上&#xff0c;Prompt&#xff08;提…

作者头像 李华
网站建设 2026/4/18 5:34:26

Injection of resource dependencies failed

一、问题描述 1、应用场景 测试大模型使用 MCP 服务 2、异常信息 org.springframework.beans.factory.BeanCreationException: Error creating bean with name mcpClientCallBaiDuMcpController: Injection of resource dependencies failedat org.springframework.context…

作者头像 李华
网站建设 2026/4/18 7:01:38

DeepSeek总结的PostgreSQL与DuckDB联动过于混沌的现状

原文地址&#xff1a;https://zenn.dev/forcia_tech/articles/20251213_advent_calendar 探索PostgreSQL与DuckDB联动过于混沌的现状 发布于 2025/12/13 这是 PostgreSQL Advent Calendar 2025 12月13日的文章。 前言 我是工程师吉田。 在 Forcia&#xff0c;我们有很多机会…

作者头像 李华
网站建设 2026/4/18 5:34:03

NATLINEAR南麟 LN6206P222MR-G SOT23-3L 线性稳压器(LDO)

特性可选择输出电压&#xff1a;可以在 1.2~5.0V 的范围内选择&#xff0c;并以 0.1V 为单位进级输出电压精度高&#xff1a;精度可达 1.0% 或 2.0%低静态功耗&#xff1a;2μA(TYP.)输入输出压差低&#xff1a;典型值 160 mV (输出为3.0V 的产品, Iout 50mA 时)输出电流大&am…

作者头像 李华