ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

Windows 10/11 安装 OpenClaw 完整步骤(2026 最新版技术指南)

Windows 10/11 安装 OpenClaw 完整步骤(2026 最新版技术指南) 1. Windows 10/11 装 OpenClaw 到底卡在哪OpenClaw 是一个面向机器人控制与自动化编排的开源框架能在 Windows 上跑本地推理、串口通信和任务调度。它适合做机器人控制应用开发、自动化流程编排以及需要本地跑模型推理的开发者。但它在 Windows 上的安装体验和 Linux 差别很大没有 apt没有预编译包MSVC 工具链、CMake 生成器、Python 虚拟环境三者版本对不上就报错。我见过最多的三类失败是CMake Error: could not find any instance of Visual Studio、cl.exe is not recognized、以及pip install -r requirements.txt在编译 C 扩展时挂掉。这篇按 2026 年最新版 OpenClaw 的仓库结构写从 PowerShell 环境准备一路到config.toml骨架和运行验证。所有命令都可以直接复制到管理员 PowerShell 里执行。如果你后面要接模型服务做推理我会在第 2 节说明怎么把 TaoToken 的 API Key 填进配置这样 OpenClaw 的模型调用环节不用自己搭服务。先明确一个前提OpenClaw 的构建依赖 MSVC 编译器不是 MinGW也不是 WSL。所以 Visual Studio Build Tools 是必装项且必须勾选 C 生成工具工作负载。下面每一步都有验证动作做完一步确认一步别一口气全跑完再排错。2. 前置准备TaoToken 与 API Key 获取OpenClaw 本身是本地框架但它的模型推理层支持通过 OpenAI 兼容接口调用远端服务。如果你不想在本地跑大模型可以用 TaoToken 作为模型服务提供方它提供 OpenAI 兼容的/v1/chat/completions接口配置进 OpenClaw 后就能直接调用。操作路径打开官网 https://taotoken.net/?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 注册后在控制台创建 API Key。控制台地址是 https://taotoken.net/console?utm_sourcetaotoken_aicg_blog_endutm_contentconsoleutm_campaignrewrite API Key 管理页在 https://taotoken.net/api-keys?utm_sourcetaotoken_aicg_blog_endutm_contentapi-keysutm_campaignrewrite 。创建后复制那串sk-开头的 Key后面写进config.toml。API 基础地址填https://taotoken.net/api注意这个地址不带任何查询参数。模型名按你控制台里开通的填比如gpt-4o或claude-3-5-sonnet这类。如果你要长期跑编码类 Agent 任务可以看 Coding Plan 页面 https://taotoken.net/coding-plan?utm_sourcetaotoken_aicg_blog_endutm_contentcoding-planutm_campaignrewrite 按用量选套餐比单次调用划算。想先验证模型通不通用模型对话页 https://taotoken.net/chat?utm_sourcetaotoken_aicg_blog_endutm_contentchatutm_campaignrewrite 发一条消息即可。接入文档在 https://taotoken.net/doc?utm_sourcetaotoken_aicg_blog_endutm_contentdocutm_campaignrewrite Claude Code 相关配置参考 https://taotoken.net/claudecode-anthropic?utm_sourcetaotoken_aicg_blog_endutm_contentclaudecode-anthropicutm_campaignrewrite 。注意API Key 只显示一次创建后立刻复制保存。写进配置文件时不要提交到 Git 仓库。3. 可复制配置PowerShell 环境与依赖安装3.1 环境检测脚本先以管理员身份打开 PowerShell跑一遍检测。这段脚本会输出每项依赖的版本和是否达标。# 检查 Windows 版本与架构 Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer $env:PROCESSOR_ARCHITECTURE # 检查管理员权限 ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) # 检查 PowerShell 版本需 5.1 $PSVersionTable.PSVersion # 检查 .NET FrameworkRelease 528040 表示 4.8 Get-ChildItem HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\ | Get-ItemPropertyValue -Name Release # 检查磁盘空间需 15GB (Get-PSDrive C).Free / 1GB如果PROCESSOR_ARCHITECTURE返回ARM64当前 OpenClaw 的 MSVC 构建链不支持需要换 x64 机器或虚拟机。磁盘空间低于 15GB 的话Build Tools 加依赖装完会爆盘。3.2 安装 Visual Studio Build Tools这是最容易失败的一步。用官方 aka.ms 短链下载然后静默安装 VCTools 工作负载。$vsUrl https://aka.ms/vs/17/release/vs_BuildTools.exe $vsPath $env:TEMP\vs_BuildTools.exe Invoke-WebRequest -Uri $vsUrl -OutFile $vsPath Test-Path $vsPath Start-Process -FilePath $vsPath -ArgumentList --passive, --wait, --norestart, --nocache, --add, Microsoft.VisualStudio.Workload.VCTools, --includeRecommended -Wait安装完成后验证编译器。注意cl和link不在系统 PATH 里必须通过vcvars64.bat加载环境 ${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat cl linkcl输出Microsoft (R) C/C Optimizing Compiler Version 19.xx就对了。如果提示找不到文件说明 Build Tools 装到了别的版本目录用Get-ChildItem ${env:ProgramFiles(x86)}\Microsoft Visual Studio看一下实际路径。3.3 安装 Python、CMake、Git三个都用静默参数装装完刷新环境变量。# Python 3.11 $pyUrl https://www.python.org/ftp/python/3.11.8/python-3.11.8-amd64.exe $pyPath $env:TEMP\python-3.11.8-amd64.exe Invoke-WebRequest -Uri $pyUrl -OutFile $pyPath Start-Process -FilePath $pyPath -ArgumentList /passive, InstallAllUsers1, PrependPath1, Include_test0 -Wait # CMake $cmUrl https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-windows-x86_64.msi $cmPath $env:TEMP\cmake-3.28.0-windows-x86_64.msi Invoke-WebRequest -Uri $cmUrl -OutFile $cmPath Start-Process msiexec -ArgumentList /i, $cmPath, /passive, ADD_CMAKE_TO_PATHSystem -Wait # Git $gitUrl https://github.com/git-for-windows/git/releases/download/v2.43.0.windows.1/Git-2.43.0-64-bit.exe $gitPath $env:TEMP\Git-2.43.0-64-bit.exe Invoke-WebRequest -Uri $gitUrl -OutFile $gitPath Start-Process -FilePath $gitPath -ArgumentList /VERYSILENT, /NORESTART, /NOCANCEL, /SP-, /SUPPRESSMSGBOXES -Wait # 刷新 PATH $env:Path [System.Environment]::GetEnvironmentVariable(Path,Machine) ; [System.Environment]::GetEnvironmentVariable(Path,User) # 验证 python --version cmake --version git --version三个版本号都打出来才算过。如果python还是找不到关掉 PowerShell 重开一个环境变量在旧会话里不生效。3.4 克隆仓库与虚拟环境$workDir C:\OpenClaw New-Item -ItemType Directory -Path $workDir -Force | Out-Null Set-Location $workDir git clone https://github.com/openclaw/openclaw.git Set-Location openclaw python -m venv venv venv\Scripts\Activate.ps1 python -m pip install --upgrade pip pip install -r requirements.txt如果Activate.ps1报执行策略错误先跑Set-ExecutionPolicy -Scope CurrentUser RemoteSigned再激活。requirements.txt里如果有需要编译的包确保当前会话已经跑过vcvars64.bat否则会报Microsoft Visual C 14.0 or greater is required。3.5 CMake 构建New-Item -ItemType Directory -Path build -Force | Out-Null Set-Location build cmake .. -G Visual Studio 17 2022 -A x64 -DCMAKE_BUILD_TYPERelease cmake --build . --config Release --parallel cmake --install . --config Release --prefix C:\Program Files\OpenClaw-G参数必须和已装的 VS 版本匹配。装的是 Build Tools 2022 就用Visual Studio 17 2022写错生成器名会直接报找不到。--parallel不加参数表示用全部核心内存小于 8GB 的话建议改成--parallel 2否则链接阶段容易 OOM。3.6 config.toml 骨架安装完成后创建配置目录和文件。OpenClaw 读的是%APPDATA%\OpenClaw\config.toml。$configDir $env:APPDATA\OpenClaw New-Item -ItemType Directory -Path $configDir -Force | Out-Null New-Item -ItemType File -Path $configDir\config.toml -Force | Out-Null notepad $configDir\config.toml把下面这段骨架粘进去把api_key换成你在 TaoToken 控制台创建的那串[server] host 127.0.0.1 port 8080 log_level info [model] provider openai-compatible base_url https://taotoken.net/api api_key sk-你的Key model_name gpt-4o timeout_seconds 60 max_retries 3 [storage] data_dir C:\\ProgramData\\OpenClaw\\data cache_size_mb 512 [runtime] max_workers 4 enable_gpu falsebase_url结尾不要加/v1OpenClaw 内部会自己拼路径。enable_gpu在没装 CUDA 的机器上保持false否则启动时报找不到cudart64_*.dll。4. 验证请求与成功结果4.1 验证安装$env:OPENCLAW_HOME C:\Program Files\OpenClaw $env:Path ;$env:OPENCLAW_HOME\bin openclaw --version openclaw config --validate openclaw config --show--version输出类似OpenClaw 0.9.x (build 20260115)。--validate返回Configuration is valid说明 TOML 语法和必填项都没问题。4.2 验证模型接口连通先用一条 curl 确认 TaoToken 的接口能通排除网络和 Key 的问题$headers { Authorization Bearer sk-你的Key Content-Type application/json } $body { model gpt-4o messages ({ role user; content ping }) } | ConvertTo-Json -Depth 5 Invoke-RestMethod -Uri https://taotoken.net/api/v1/chat/completions -Method Post -Headers $headers -Body $body返回 JSON 里choices[0].message.content有内容就说明 Key 和网络都正常。如果返回 401检查 Key 有没有复制全返回 404检查base_url是不是写成了带/v1的。4.3 启动 OpenClaw 并跑测试openclaw start openclaw status openclaw test --unit openclaw logs --tail 50status显示running且端口 8080 在监听就说明服务起来了。test --unit全绿表示核心模块加载正常。logs里如果出现model provider connected说明模型层也接上了。5. 本篇常见错排查5.1 CMake 找不到 Visual Studio报错原文CMake Error at CMakeLists.txt: could not find any instance of Visual Studio。原因是 Build Tools 没装 VCTools 工作负载或者装了但 CMake 版本太老识别不了 VS 2022。先确认cl能跑再确认cmake --version大于 3.15。两个都满足还报错删掉build目录重新生成Set-Location .. Remove-Item build -Recurse -Force New-Item -ItemType Directory -Path build -Force | Out-Null Set-Location build cmake .. -G Visual Studio 17 2022 -A x64 -DCMAKE_BUILD_TYPERelease5.2 pip 安装依赖时编译失败报错原文error: Microsoft Visual C 14.0 or greater is required。这是因为当前 PowerShell 会话没有加载 MSVC 环境变量。先跑vcvars64.bat再激活虚拟环境再装依赖 ${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat venv\Scripts\Activate.ps1 pip install -r requirements.txt顺序不能反vcvars64.bat必须在激活 venv 之前或之后都行但必须在pip install之前。5.3 编译阶段链接报错 LNK1104报错原文LNK1104: cannot open file python311.lib。这是 Python 开发库没装。用官方安装器重跑一遍勾选Include_lib或者手动把C:\Program Files\Python311\libs加到 CMake 的-DPYTHON_LIBRARY参数里cmake .. -G Visual Studio 17 2022 -A x64 -DCMAKE_BUILD_TYPERelease -DPYTHON_LIBRARYC:\Program Files\Python311\libs\python311.lib -DPYTHON_INCLUDE_DIRC:\Program Files\Python311\include5.4 启动时报端口占用报错原文OSError: [WinError 10048] 通常每个套接字地址只允许使用一次。8080 被别的进程占了。查一下是谁Get-NetTCPConnection -LocalPort 8080 | Select-Object OwningProcess Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess要么停掉那个进程要么改config.toml里的port为 8081 或其他空闲端口然后openclaw config --reload。5.5 模型调用返回 401 或超时401 基本都是 Key 的问题复制时带了空格、Key 被撤销、或者base_url写错。超时的话把timeout_seconds从 60 调到 120max_retries调到 5。如果公司网络有出口限制确认taotoken.net能正常解析。6. 装完之后怎么接模型服务OpenClaw 装好只是第一步真正跑起来要靠模型层。上面config.toml里的[model]段就是接 TaoToken 的地方改完配置用openclaw config --reload热加载不用重启服务。如果你要验证不同模型在 OpenClaw 里的表现直接去模型对话页 https://taotoken.net/chat?utm_sourcetaotoken_aicg_blog_endutm_contentchatutm_campaignrewrite 试一条确认模型名和返回格式对得上再写进配置。长期跑编码类 Agent 任务的话Coding Plan https://taotoken.net/coding-plan?utm_sourcetaotoken_aicg_blog_endutm_contentcoding-planutm_campaignrewrite 按用量计费比单次调用省。API Key 管理和新建都在 https://taotoken.net/api-keys?utm_sourcetaotoken_aicg_blog_endutm_contentapi-keysutm_campaignrewrite 接入细节看文档 https://taotoken.net/doc?utm_sourcetaotoken_aicg_blog_endutm_contentdocutm_campaignrewrite 。最后提醒一个实操细节config.toml里的路径用双反斜杠\\或者正斜杠/单反斜杠在 TOML 里是转义字符C:\ProgramData会被解析成C:ProgramData启动时报目录不存在。这个坑我踩过排查了半小时才发现是转义问题。
返回列表