【大模型】openclaw调用本地模型实验记录1
openclaw安装记录
创建时间:2026-03-11
更新时间:2026-03-11
文章目录
- openclaw安装记录
-
- 目录
- 安装环境准备
- Miniconda 安装
- OpenClaw 安装方式选择
- OpenClaw 初始配置(对接 Ollama 本地模型)
- WSL 无法访问 Windows 上 Ollama 的排查与修复
- OpenClaw Dashboard / Gateway 启动与认证
- 最终验证结果
- 常见报错及解决
- `openclaw: command not found`
- `Failed to discover Ollama models: TypeError: fetch failed`
- `curl: (7) Failed to connect to 127.0.0.1 port 11434`
- `ERR_CONNECTION_REFUSED`
- `Unauthorized`
- `gateway token missing`
- `gateway token mismatch`
- 关键命令汇总
- 总结
目录
- 安装环境准备
- Miniconda 安装
- OpenClaw 安装方式选择
- OpenClaw 初始配置(对接 Ollama 本地模型)
- WSL 无法访问 Windows 上 Ollama 的排查与修复
- OpenClaw Dashboard / Gateway 启动与认证
- 最终验证结果
- 常见报错及解决
安装环境准备
问:当前基础环境是什么状态?
已具备的环境:
- 已安装
Ollama - 已安装
WSL - 已安装
Miniconda - 尚未完成
OpenClaw的正确接入配置
问:最终目标是什么?
目标链路为:
- OpenClaw 作为 Agent
- 调用本地 Ollama 模型
- 通过 Dashboard / Gateway 进行交互
- 后续再扩展为调用 Python 自动生成 PPT
注意:
- 本次先完成 OpenClaw + Ollama 本地模型跑通
- Python 自动生成 PPT 属于下一阶段
Miniconda 安装
问:Miniconda 从哪里下载?
最终使用的是 官方安装包,未继续使用阿里云镜像。
推荐下载版本:
Miniconda3-py312_26.1.1-1-Windows-x86_64.exe
也可使用 latest 版:
Miniconda3-latest-Windows-x86_64.exe
问:为什么不继续用阿里云镜像?
因为访问阿里云镜像时出现了无法连接或页面已移动的问题,因此改为使用官方源下载安装。
注意:
- 安装 Miniconda 时,优先选择较新的稳定版本
- Python 3.12 兼容性通常更稳
OpenClaw 安装方式选择
问:OpenClaw 可以装在 Windows 本机吗?
实际操作中,选择了:
- 在 WSL 的 Ubuntu 环境中安装 OpenClaw
- 不在 Windows 本机直接作为主要运行环境安装
问:OpenClaw 可以离线安装吗?
结论:
- 不适合直接做纯离线一键安装
- 更现实的方式是:
- 先联网安装一次
- 或者在另一台联网环境中准备依赖后迁移
注意:
- OpenClaw 的安装和依赖管理更适合联网完成
- Windows 上推荐配合 WSL 使用,兼容性更好
问:如何安装 OpenClaw?
在 WSL 中执行安装脚本:
curl -fsSL https://openclaw.ai/install.sh | bash
安装后刷新当前 shell:
source ~/.bashrc
验证命令是否可用:
openclaw --version
问:如果 openclaw: command not found 怎么办?
先刷新 shell 环境:
source ~/.bashrc
hash -r
openclaw --version
如果仍然失败,再检查:
node -v
npm -v
npm prefix -g
echo "$PATH"
OpenClaw 初始配置(对接 Ollama 本地模型)
问:如何重新进入 OpenClaw 配置向导?
执行:
openclaw onboard
问:向导里应该怎么选模型提供方?
在实际操作中:
- 没有直接看到
Ollama选项 - 先选择了:
Skip for now
然后继续完成引导
问:后续模型怎么设置为本地 Ollama?
在模型选择阶段,选择:
Enter model manually
把默认模型改为:
ollama/qwen3:8b
问:为什么选择 qwen3:8b,而不是 deepseek-r1:1.5b?
优先使用:
qwen3:8b
原因:
- 参数规模更大
- 更适合作为 OpenClaw 的主聊天模型
- 在工具调用、对话稳定性上更合适
问:向导中其他选项怎么处理?
整体处理方式如下:
- Channel 选择:
Skip for now
- Web Search:
Skip for now
- Skills:
- 先启用检查
- 依赖安装选择
Skip for now
- Hooks:
Skip for now
- 各类 API Key:
- Notion / Google Places / Gemini / OpenAI / ElevenLabs 等均先选择
No
- Notion / Google Places / Gemini / OpenAI / ElevenLabs 等均先选择
注意:
- 当前目标只是本地模型可用,不需要先配置消息渠道、搜索、外部 API
- 多余集成后续需要时再补充
问:如何查看模型配置是否生效?
先刷新环境,再查看状态:
source ~/.bashrc
openclaw models status
如果显示默认模型为:
ollama/qwen3:8b
则说明模型配置已写入。
问:为什么还提示缺少 ollama 认证?
为让 OpenClaw 完成 provider 检查,设置占位环境变量:
export OLLAMA_API_KEY="ollama-local"
openclaw models status
最终状态中应看到:
Default : ollama/qwen3:8b
Configured models (1): ollama/qwen3:8b
WSL 无法访问 Windows 上 Ollama 的排查与修复
问:为什么 OpenClaw 无法发现 Ollama 模型?
初始报错为:
Failed to discover Ollama models: TypeError: fetch failed
随后在 WSL 中测试:
curl http://127.0.0.1:11434/api/tags
结果:
connection refused
说明:
- WSL 内访问
127.0.0.1:11434不通 - Windows 上的 Ollama 没有被 WSL 正确访问到
问:如何让 Windows 上的 Ollama 对外可访问?
在 Windows 中新增环境变量:
变量名:
OLLAMA_HOST
变量值:
0.0.0.0:11434
然后完全重启 Ollama。
问:如何验证 Ollama 是否已经监听正确端口?
在 Windows CMD 或 PowerShell 中执行:
netstat -ano | findstr 11434
正确监听结果示例:
TCP 0.0.0.0:11434 0.0.0.0:0 LISTENING
TCP [::]:11434 [::]:0 LISTENING
问:为什么仍然无法从 WSL 连接?
后续判断为:
- Windows 防火墙可能拦截了
11434 - WSL 网络模式导致 localhost 互通不完整
问:如何放行 Ollama 端口?
在 管理员 PowerShell 中执行:
New-NetFirewallRule -DisplayName "Allow Ollama 11434" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 11434
问:为什么还是不通?
进一步排查发现,WSL 仍然无法通过宿主机 IP 正常访问 Ollama,因此继续修改 WSL 网络模式。
问:如何开启 WSL mirrored networking?
在 Windows 中创建或编辑文件:
C:\Users\lenovo\.wslconfig
内容如下:
[wsl2]
networkingMode=mirrored
然后重启 WSL:
wsl --shutdown
wsl
问:如何验证 WSL 已经能访问 Windows 上的 Ollama?
进入 WSL 后执行:
curl http://localhost:11434/api/tags
成功返回模型列表,例如:
{"models":[{"name":"qwen3:8b"}, {"name":"deepseek-r1:1.5b"}]}
这说明:
- WSL 已经可以通过
localhost访问 Windows 上的 Ollama - OpenClaw 调用本地模型的网络链路已打通
注意:
- 这一步是整个安装过程中最关键的网络修复步骤
- 如果
curl http://localhost:11434/api/tags不通,OpenClaw 就无法正常发现 Ollama 模型
OpenClaw Dashboard / Gateway 启动与认证
问:为什么打开 http://127.0.0.1:18789/ 提示无法访问?
原因是 Gateway 没有以前台方式运行,或者未正常建立 WebSocket 监听。
问:如何前台启动 Gateway?
在 WSL 中执行:
openclaw gateway --port 18789
正常输出示例:
[gateway] agent model: ollama/qwen3:8b
[gateway] listening on ws://127.0.0.1:18789
[browser/server] Browser control listening on http://127.0.0.1:18791/ (auth=token)
问:为什么打开的是 Canvas 页面?
误打开了:
http://127.0.0.1:18789/__openclaw__/canvas/
这是 Canvas 测试页,不是聊天控制台。
应打开的是 Dashboard URL,而不是 Canvas URL。
问:为什么打开 18791 提示 Unauthorized?
因为 Browser Control 启用了 token 认证。
问:如何获取正确的 dashboard token?
执行:
openclaw config get gateway.auth.token
或者更直接地打印完整 Dashboard URL:
openclaw dashboard --no-open
示例输出:
Dashboard URL: http://127.0.0.1:18789/#token=xxxxxxxxxxxxxxxxxxxxxxxx
问:最终应该打开哪个链接?
直接打开 openclaw dashboard --no-open 输出的完整链接,例如:
http://127.0.0.1:18789/#token=b9e410df30709779cc331a63de57813922e0f9c6ec475429
问:为什么之前一直提示 gateway token missing 或 token mismatch?
原因包括:
- 浏览器中缓存了旧 token
- 没有打开带
#token=...的完整链接 - 误打开了不带 token 的页面
- 打开了错误端口或错误页面
如需清理浏览器缓存中的旧 token,可在控制台执行:
localStorage.clear(); sessionStorage.clear(); location.reload();
注意:
18789是 Gateway Dashboard 入口18791是 Browser Control 监听地址,但当前实际使用中,以dashboard --no-open输出的完整 URL 最稳- 一定要使用 带 token 的完整链接
最终验证结果
问:最终是否已经跑通?
已经跑通。
最终成功状态表现为:
- OpenClaw 页面正常打开
- 默认模型为:
ollama/qwen3:8b
- 页面中可以发送消息并获得回复
- 已完成:
- OpenClaw 安装
- WSL 联通 Windows Ollama
- Gateway 启动
- Dashboard token 认证
- 本地模型响应验证
问:当前已经具备什么能力?
当前已经具备:
- 通过 OpenClaw 控制台与本地
qwen3:8b模型对话 - 后续可以继续扩展:
- Python 工具调用
- 自动生成 PPT
- 其他技能或渠道接入
常见报错及解决
openclaw: command not found
原因
- shell 环境未刷新
- PATH 未生效
解决
source ~/.bashrc
hash -r
openclaw --version
Failed to discover Ollama models: TypeError: fetch failed
原因
- WSL 无法访问 Windows 上的 Ollama
OLLAMA_API_KEY未设置- 网络模式或防火墙问题
解决
- 设置占位认证:
export OLLAMA_API_KEY="ollama-local"
- 测试 Ollama 接口:
curl http://localhost:11434/api/tags
- 若不通,则继续:
- 设置
OLLAMA_HOST=0.0.0.0:11434 - 重启 Ollama
- 放行 Windows 防火墙端口
11434 - 开启 WSL mirrored networking
- 设置
curl: (7) Failed to connect to 127.0.0.1 port 11434
原因
WSL 中的 localhost 不能直接访问 Windows 上的 Ollama。
解决
- 在 Windows 中设置:
OLLAMA_HOST=0.0.0.0:11434
- 配置:
[wsl2]
networkingMode=mirrored
- 重启 WSL:
wsl --shutdown
wsl
ERR_CONNECTION_REFUSED
原因
- Gateway 未启动
- 打开的不是正确的控制页面
- 端口未监听
解决
启动 Gateway:
openclaw gateway --port 18789
Unauthorized
原因
Control UI 开启了 token 认证,但浏览器未携带正确 token。
解决
- 获取 token:
openclaw config get gateway.auth.token
- 获取完整 dashboard 链接:
openclaw dashboard --no-open
- 打开带 token 的完整 URL
gateway token missing
原因
浏览器未携带 token,或 token 未写入页面状态。
解决
直接打开:
openclaw dashboard --no-open
输出的完整 URL。
gateway token mismatch
原因
浏览器里缓存了旧 token。
解决
在浏览器控制台执行:
localStorage.clear(); sessionStorage.clear(); location.reload();
然后重新打开带 token 的 dashboard 链接。
关键命令汇总
OpenClaw 安装
curl -fsSL https://openclaw.ai/install.sh | bash
source ~/.bashrc
openclaw --version
进入向导
openclaw onboard
查看模型状态
export OLLAMA_API_KEY="ollama-local"
openclaw models status
测试 Ollama 接口
curl http://localhost:11434/api/tags
启动 Gateway
openclaw gateway --port 18789
获取 Gateway Token
openclaw config get gateway.auth.token
获取完整 Dashboard 链接
openclaw dashboard --no-open
Windows 放行防火墙
New-NetFirewallRule -DisplayName "Allow Ollama 11434" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 11434
检查 Ollama 监听
netstat -ano | findstr 11434
重启 WSL
wsl --shutdown
wsl
总结
本次 openclaw 安装与接入的核心难点不在安装命令本身,而在于:
- WSL 如何访问 Windows 上的 Ollama
- Gateway 与 Dashboard 的 token 认证
- 区分 Canvas、Gateway、Dashboard 三种入口
最终已成功完成:
- OpenClaw 安装
- Ollama 本地模型接入
qwen3:8b设为默认模型- WSL 与 Windows 之间的 Ollama 联通
- OpenClaw Dashboard 成功登录并对话
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)