手把手教你Windows里安装OpenClaw小龙虾

张开发
2026/5/30 19:47:23 15 分钟阅读
手把手教你Windows里安装OpenClaw小龙虾
这篇文章是一篇详细指导如何在 Windows 系统上安装和配置 AI 开发工具 “OpenClaw” 的教程作者将其昵称为“小龙虾”。核心内容总结如下安装思路由于 OpenClaw 原生更适合 Linux 环境文章推荐在 Windows 中使用WSL2​ 来创建一个 Linux 虚拟机并在其中进行安装这比直接在 Windows 上安装更稳定、问题更少。主要安装步骤第一步安装 WSL2。在 Windows PowerShell 中运行wsl --install命令安装后需重启电脑。第二步在 WSL2 中安装 Ubuntu 24.04。运行wsl --install Ubuntu-24.04命令安装官方推荐的 Linux 发行版。安装过程中需创建非root用户如openclaw并建议在安装后立即执行系统更新。第三步强烈推荐将 Ubuntu 系统迁移到非系统盘。为了避免占用 C 盘空间文章指导用户通过export和import命令将默认安装在 C 盘的 Ubuntu 系统完整迁移到其他盘如 D 盘。第四步安装 OpenClaw。在 WSL 的 Ubuntu 终端中运行官方的一键安装命令curl -fsSL https://openclaw.ai/install.sh | bash。文章也提到如果安装失败可能需要手动安装特定依赖例如libvips-dev库。后续配置首次配置安装完成后程序会引导用户进行一些初始设置如选择快速开始模式、配置模型提供商等。配置大模型 API运行openclaw configure命令来配置大模型服务。作者以自己的经验为例说明如果使用 Minimax 的服务需要选择带(CN)后缀的选项并注意正确的域名拼写。启动图形界面运行openclaw dashboard命令会生成一个带本地令牌的链接。按住Ctrl键点击该链接即可在浏览器中打开 OpenClaw 的图形化操作界面开始使用。wsl -vwsl --install Ubuntu-24.04sudo apt updatesudo apt upgradeexitwsl -l -v///*wsl --shutdown*//wsl --export Ubuntu-24.04 D:\slb-ubuntu.tarwsl --unregister Ubuntu-24.04mkdir d:\wslwsl --import Ubuntu D:\wsl\ubuntu D:\slb-ubuntu.tar --version 2wsl -d Ubuntu# 或直接wsl3.7 Windows里访问Linux的文件在 Windows 资源管理器中输入以下地址可以直接访问 WSL 内的文件非常方便\\wsl$\Ubuntu官方推荐的安装步骤在 WSL 的 Ubuntu 终端中运行curl -fsSL https://openclaw.ai/install.sh | bash到底哪个是Yes网关认证配置诊断网关认证已关闭或缺少令牌Token。令牌认证是目前推荐的默认安全方式包括本地回环通信。解决方案程序在最后给出了一个交互式选项Generate and configure a gateway token now?为了启用安全的认证您应该选择Yes。选择后OpenClaw 会自动为您生成并配置一个访问令牌。网关\\wsl$\Ubuntu\home\administrator\.openclawgateway: {mode:local,bind: loopback,port: 18789,auth: {mode: token,token: }},配置模型sudo ss -tulpn | grep :18789[sudo] password for administrator:tcp LISTEN 0 511 127.0.0.1:18789 0.0.0.0:* users:((openclaw-gatewa,pid12637,fd22))tcp LISTEN 0 511 [::1]:18789 [::]:* users:((openclaw-gatewa,pid12637,fd23))API Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1API Key: sk-3Endpoint ID: [留空] 或 dashscope【腾讯文档】总结这篇文章https://docs.qq.com/aio/DZmVzeGx3WEp2U2ROhttps://docs.qq.com/aio/DZmVzeGx3WEp2U2RO我明白问题了你选择的 LiteLLM 配置界面显示的是默认模型而不是阿里云百炼的模型。因为 LiteLLM 默认不知道你这个 key 是阿里云百炼的。解决方案方案1使用 Custom Provider推荐最简单退回到上一级选择 Custom Provider然后这样配置model: qwen-maxapiBase: https://dashscope.aliyuncs.com/compatible-mode/v1apiKey: sk- 具体操作按 ESC 或选择返回选择 Custom ProviderModel: qwen-max或你想用的模型API Base: https://dashscope.aliyuncs.com/compatible-mode/v1API Key: sk-方案2继续用 LiteLLM但需要配置模型映射如果你坚持用 LiteLLM需要手动配置模型映射。配置文件需要这样写agents:defaults:model: litellm/qwen-max # 注意这里是 litellm/ 前缀provider: litellmproviders:litellm:env:DASHSCOPE_API_KEY: sk- model_list:- model_name: qwen-maxlitellm_params:model: openai/qwen-maxapi_base: https://dashscope.aliyuncs.com/compatible-mode/v1api_key: os.environ/DASHSCOPE_API_KEY我的建议选择方案1Custom Provider原因配置更简单3个参数搞定不需要理解 LiteLLM 的复杂配置直接使用阿里云百炼的 OpenAI 兼容接口可用模型名称qwen-max最强qwen-plus平衡qwen-turbo最快qwen-vl-plus多模态qwen-coder-plus代码你想用哪个方案我可以给你更详细的操作步骤。Select sections to configure ModelModel/auth provider Custom ProviderAPI Base URLhttp://127.0.0.1:11434How do you want to provide this API key?Paste API key nowAPI Key (leave blank if not required) 这是在用本地大模型回复 曹飞书:Select sections to configure ModelModel/auth provider Custom ProviderAPI Base URLhttp://127.0.0.1:11434How do you want to provide this API key?Paste API key nowAPI Key (leave blank if not required) 这是在用本地大模型对你看到的 http://127.0.0.1:11434 是 Ollama本地大模型的默认地址。你需要改的配置把默认值改成阿里云百炼的第一步修改 API Base URLhttp://127.0.0.1:11434改成https://dashscope.aliyuncs.com/compatible-mode/v1第二步输入 API Keysk-第三步设置模型名称Model 填qwen-max或者你想要的其他模型qwen-plus平衡qwen-turbo最快qwen-vl-plus多模态完整配置示例API Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1API Key: sk-Model: qwen-max为什么默认是 127.0.0.1:1143411434 是 Ollama 的默认端口Ollama 是一个流行的本地大模型运行工具如果你本机装了 Ollama就可以用本地模型运行 OpenClaw但你现在要用阿里云的云端模型所以需要改成阿里云的地址配置完成后OpenClaw 就会调用阿里云百炼的 API而不是本地模型了。继续填写就对了Select sections to configureModelModel/auth providerCustom ProviderAPI Base URLhttp://127.0.0.1:11434How do you want to provide this API key?Paste API key nowAPI Key (leave blank if not required)sk-Endpoint compatibilityOpenAI-compatible (Uses /chat/completions)Anthropic-compatibleUnknown (detect automatically) 这一步选什么回复 曹飞书:Select sections to configureModelModel/auth providerCustom ProviderAPI Base URLhttp://127.0.0.1:11434How do you want to provide this API key?Paste API key nowAPI Key (leave blank if not required)sk-Endpoint compatibilityOpenAI-compatible (Uses /chat/completions)Anthropic-compatibleUnknown (detect automatically) 这一步选什么选择 OpenAI-compatible (Uses /chat/completions)为什么选这个阿里云百炼的 compatible-mode/v1 完全兼容 OpenAI API✅ 使用 /chat/completions 端点✅ 请求格式和 OpenAI 一致✅ 响应格式和 OpenAI 一致✅ 支持所有 OpenAI 的参数temperature, max_tokens 等如果选择 Unknown 会怎样也可以选择 Unknown (detect automatically)系统会自动检测。但既然你知道它是 OpenAI 兼容的直接选择更明确。总结选择OpenAI-compatible配置就完成了然后就可以开始使用阿里云百炼的模型了。What would you like to change?Change base URLAPI Base URLhttps://dashscope.aliyuncs.com/compatible-mode/v1How do you want to provide this API key?Paste API key nowAPI Key (leave blank if not required)sk-Verification successful.Endpoint ID 这个填什么回复 曹飞书:What would you like to change?Change base URLAPI Base URLhttps://dashscope.aliyuncs.com/compatible-mode/v1How do you want to provide this API key?Paste API key nowAPI Key (leave blank if not required)sk-Verification successful.Endpoint ID 这个填什么可以留空不填 或者填 dashscope说明对于阿里云百炼的 OpenAI 兼容模式Endpoint ID 是可选的不是必需的。选项1留空推荐直接按 Enter 或跳过不填任何内容。选项2填个标识名如果想填可以填dashscope 百炼的英文名aliyun 阿里云qwen 通义千问最终配置总结API Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1API Key: sk-Endpoint ID: [留空] 或 dashscope验证成功 说明你的 API Key 是有效的继续下一步配置模型名称就好了怎么检查 和使用回复 曹飞书:怎么检查 和使用配置完成后可以这样检查和使用1. 检查配置状态方法1查看配置文件# 查看当前配置openclaw config get或者直接查看配置文件cat ~/.openclaw/config.yaml方法2测试模型调用直接在飞书里给我发个测试消息测试一下你现在用的什么模型我会回复显示当前使用的模型信息。2. 使用配置好的模型在对话中指定模型如果你想切换到不同的模型可以这样请用 qwen-turbo 快速回答什么是人工智能或者明确指定使用模型 qwen-plus 回答这个问题...查看支持的模型你可以问列出可用的模型列表3. 重启服务如果需要如果配置后没有立即生效重启 OpenClawsh /workspace/projects/scripts/restart.sh4. 测试完整流程给我发几个测试问题简单问答你好现在几点了复杂任务帮我写一个 Python 脚本来计算斐波那契数列验证模型你现在用的是什么模型5. 查看日志排查问题如果有问题查看日志# 查看最近的日志tail -100 ~/.openclaw/logs/gateway.log6. 切换模型如果你想更换默认模型可以重新运行配置流程或直接修改配置文件agents:defaults:model: qwen-turbo # 改成其他模型现在你可以发个消息测试一下告诉我 你现在用的是什么模型我会告诉你当前的配置信息要测试吗https://developer.aliyun.com/article/1712265

更多文章