系统环境:阿里云轻量应用服务器,Alibaba Cloud Linux 3(基于 RHEL 8),默认 Python 3.6.8
背景
Hermes Agent 要求 Python 3.11+,而阿里云 Alinux 默认自带的是 Python 3.6.8,加上国内网络环境对 GitHub、PyPI、npm 都不太友好,直接按照官方文档安装会遇到各种坑。本文记录了完整的安装过程和踩坑解决方案。
环境准备
1. 安装 Python 3.11
Alinux 3 的 yum 源里自带 Python 3.11,直接装:
sudo yum install -y python3.11 python3.11-devel python3.11-pip
验证:
python3.11 --version
# Python 3.11.x
2. 克隆 Hermes Agent 仓库
国内直连 GitHub 大概率超时,推荐用镜像站:
# 方案 A:GitCode 镜像(推荐)
git clone https://gitcode.com/GitHub_Trending/he/hermes-agent.git ~/.hermes/hermes-agent
# 方案 B:GitHub 加速站
git clone https://ghfast.top/https://github.com/NousResearch/hermes-agent.git ~/.hermes/hermes-agent
安装步骤
1. 创建虚拟环境
关键:必须用 python3.11 创建 venv,不能用系统默认的 python3(3.6)。
cd ~/.hermes/hermes-agent
python3.11 -m venv venv
source venv/bin/activate
2. 配置国内 PyPI 镜像源
pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
如果不换源,默认走 PyPI 官方源,国内大概率超时。
3. 安装 Hermes Agent
pip install -e ".[all]" -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
这一步依赖较多,耐心等待。
验证安装成功:
hermes --version
# Hermes Agent v0.11.0 (2026.4.23)
如果提示 command not found,创建全局链接:
ln -sf ~/.hermes/hermes-agent/venv/bin/hermes /usr/local/bin/hermes
初始化配置
一条命令搞定所有配置(模型、网关、工具):
hermes setup
按向导提示逐步完成:
- 选择 AI 模型:支持 DeepSeek、通义千问、Kimi/Moonshot、MiniMax 等国内模型,直接填 API Key 即可
- 选择消息网关:微信(Weixin)、飞书(Feishu)、企业微信(WeCom)、Telegram 等
- 工具配置:浏览器、文件操作、终端等
也可以单独配置各项:
hermes model # 切换/配置 AI 模型
hermes gateway setup # 配置消息网关
hermes tools # 配置工具
踩坑记录
坑 1:系统 Python 版本太低
现象: pip install 报错 No matching distribution found for setuptools>=61.0
原因: 系统 Python 是 3.6,setuptools 最高只到 59.6.0,而 Hermes 要求 Python 3.11+
解决: 安装 python3.11 并用它创建 venv
坑 2:pip 版本太旧不支持 config 命令
现象: pip config set 报 ERROR: unknown command "config"
原因: 系统自带 pip 9.0.3,config 命令需要 pip 10+
解决: 手动创建 pip 配置文件,或在 venv 中升级 pip
mkdir -p ~/.pip
cat > ~/.pip/pip.conf << 'EOF'
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
EOF
坑 3:PyPI 找不到 hermes-agent 包
现象: pip install hermes-agent 报 No matching distribution found
原因: Hermes Agent 不在 PyPI 上,需要从源码安装
解决: 先 clone 仓库,再用 pip install -e ".[all]" 安装
坑 4:Alinux 不支持 python3-venv
现象: yum install python3-venv 报找不到包
原因: RHEL 系的 venv 模块随 Python 自带,不需要额外安装
解决: 直接用 python3.11 -m venv venv 即可
消息网关选择
| 平台 | 国内直连 | 配置难度 | 说明 |
|---|---|---|---|
| 微信 | 直连 | 中 | 使用腾讯 iLink Bot API,扫码即连,无需公网 IP |
| 飞书 | 直连 | 低 | 需在开放平台创建企业自建应用 |
| 企业微信 | 直连 | 中 | 需要 Webhook 或长连接 |
| Telegram | 需代理 | 低 | 需要能访问 Telegram API |
常用命令
hermes # 启动交互式对话
hermes setup # 完整配置向导
hermes model # 切换模型
hermes gateway # 启动消息网关
hermes doctor # 诊断问题
hermes --continue # 恢复上次对话
后台运行
SSH 断开后网关会停止,建议用 tmux 或 systemd 保持运行:
# 方案 A:tmux
tmux new -s hermes
hermes gateway
# Ctrl+B 然后按 D 脱离
# 方案 B:nohup
nohup hermes gateway > ~/.hermes/gateway.log 2>&1 &