在Windows 11中用ollama和本地小模型运行claude code
本文详细介绍了在Windows系统上搭建Ollama和Claude AI开发环境的完整流程。主要内容包括:1)下载安装Ollama客户端并运行Qwen小型语言模型;2)配置Node.js环境并安装Claude-code工具;3)解决Windows系统bash兼容性问题,通过安装Git Bash提供支持;4)完成Claude AI的环境变量配置和权限设置。文章提供了详细的命令行操作步骤和注意事项,帮
·
1.下载ollama安装包并安装
wget -c https://github.com/ollama/ollama/releases/download/v0.17.6/OllamaSetup.exe -O Ollama0176.exe
然后双击exe文件,按默认安装。再启动Ollama客户端。
2.拉取运行qwen小模型
C:\d>ollama run qwen3.5:0.8b --think=false
pulling manifest
pulling afb707b6b8fa: 100% ▕█████████████▏ 1.0 GB
pulling 9be69ef46306: 100% ▕█████████████▏ 11 KB
pulling 9371364b27a5: 100% ▕█████████████▏ 65 B
pulling b14c6eab49f9: 100% ▕█████████████▏ 476 B
verifying sha256 digest
writing manifest
success
3.下载并安装node和claude-code
wget https://npmmirror.com/mirrors/node/v25.6.0/node-v25.6.0-win-x64.zip
解压缩到C:\d\nodewin, 再设置搜索路径PATH
C:\d\nodewin\node-v25.6.0-win-x64>set path=%path%;C:\d\nodewin\node-v25.6.0-win-x64
C:\d\testcc>npm install -g @anthropic-ai/claude-code
added 2 packages in 6m
1 package is looking for funding
run `npm fund` for details
C:\d\testcc>set ANTHROPIC_BASE_URL="http://localhost:11434"
C:\d\testcc>set ANTHROPIC_AUTH_TOKEN="ollama"
C:\d\testcc>set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
C:\d\testcc>set ANTHROPIC_MODEL=qwen3.5:0.8b
C:\d\testcc>claude --debug "帮我写一个 TODO API"
Claude Code on Windows requires git-bash (https://git-scm.com/downloads/win). If installed but not in PATH, set environment variable pointing to your bash.exe, similar to: CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\Git\bin\bash.exe
此时可以安装claude-code,但执行报错。Windows11本身有个bash, 但不满足calude code的要求
C:\d\testcc>bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
4.下载并安装git-win
C:\d\testcc>wget https://github.com/git-for-windows/git/releases/download/v2.53.0.windows.1/Git-2.53.0-64-bit.exe
或者用镜像加速
C:\d>wget -c https://mirrors.sdu.edu.cn/github-release/1772581475/github-release/git-for-windows_git/v2.53.0.windows.1/Git-2.53.0-64-bit.exe
双击用默认安装即可,
C:\d\testcc>npm install -g @anthropic-ai/claude-code
changed 2 packages in 50s
1 package is looking for funding
run `npm fund` for details
测试ollama服务正常
C:\d\testcc>curl http://localhost:11434/api/tags
{"models":[{"name":"qwen3.5:0.8b","model":"qwen3.5:0.8b","modified_at":"2026-03-05T18:22:56.8283081+08:00","size":1036046583,"digest":"f3817196d142eaf72ce79dfebe53dcb20bd21da87ce13e138a8f8e10a866b3a4","details":{"parent_model":"","format":"gguf","family":"qwen35","families":["qwen35"],"parameter_size":"873.44M","quantization_level":"Q8_0"}}]}
C:\d\testcc>set ANTHROPIC_BASE_URL="http://localhost:11434"
C:\d\testcc>set ANTHROPIC_AUTH_TOKEN="ollama"
C:\d\testcc>set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
C:\d\testcc>set ANTHROPIC_MODEL=qwen3.5:0.8b
C:\d\testcc>ollama launch claude
Model Configuration
先要求选择一些界面的东西,
Let's get started.
Choose the text style that looks best with your terminal
To change this later, run /theme
> 1. Dark mode √
2. Light mode
3. Dark mode (colorblind-friendly)
4. Light mode (colorblind-friendly)
5. Dark mode (ANSI colors only)
6. Light mode (ANSI colors only)
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
1 function greet() {
2 - console.log("Hello, World!");
2 + console.log("Hello, Claude!");
3 }
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
Syntax highlighting available only in native build
安全提示
Security notes:
Claude can make mistakes
You should always review Claude's responses, especially when
running code.
Due to prompt injection risks, only use it with code you trust
For more details see:
https://code.claude.com/docs/en/security
Press Enter to continue…
设置权限,
Accessing workspace:
C:\d\testcc
Quick safety check: Is this a project you created or one you trust? (Like your own code, a well-known open source project, or work from your team). If not, take a moment to
review what's in this folder first.
Claude Code'll be able to read, edit, and execute files here.
Security guide
> 1. Yes, I trust this folder
2. No, exit
Enter to confirm · Esc to cancel
然后就可以接收命令了
Launching Claude Code with qwen3.5:0.8b...
╭─── Claude Code v2.1.69 ─────────────────────────────────────────────────────────────────────╮
│ │ Tips for getting started │
│ Welcome back! │ Ask Claude to create a new app or clone a repository │
│ │ ──────────────────────────────────────────────────── │
│ │ Recent activity │
│ ▐▛███▜▌ │ No recent activity │
│ ▝▜█████▛▘ │ │
│ ▘▘ ▝▝ │ │
│ qwen3.5:0.8b · API Usage Billing │ │
│ C:\d\testcc │ │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯
/model to try Opus 4.6
> /init
● CLAUDE.md
Codebase Structure
The project appears to be an educational or testing project with minimal implementation. I've examined the files
present and created this documentation file.
c:\d\testcc\
.gitignore
README.md
main.py
src/
main.py
__init__.py
tests/
test_main.py
conftest.py
requirements.txt
Features and Functionality
Core Module (src/main.py)
- File: main.py in src/ directory
- Purpose: Main module containing the application logic
- Features:
- Simple utility functions for operations
- Basic command-line interface (CLI) support
- Implementation: Uses standard Python modules and file system operations
Testing Module (tests/test_main.py)
- File: test_main.py in tests/ directory
- Purpose: Unit tests covering basic functionality
- Tests:
- Basic utility function calls
- Integration with CLI commands
- File system operations
Configuration and Environment Setup
Dependencies (requirements.txt)
Note: No external dependencies detected in the source code
Project Structure Analysis
The codebase consists of:
1. Minimal Core Implementation: A basic Python application with utilities
2. Testing Infrastructure: Simple test structure
3. Configuration Files: Standard Python project setup files
4. No External Tools Required: No libraries beyond standard Python modules
Development Commands
Available Commands
- Build:
# Install dependencies (if required)
pip install -r requirements.txt
# Create a new package
python setup.py build
- Test Suite: Run all tests
pytest tests/
- Run Specific Tests: Execute specific test file
pytest tests/test_main.py::test_basic_function
Development Workflow
# Create a new Python package (if not exists)
python setup.py develop
# Run all tests
pytest tests/
# View project structure
ls -la src/ tests/
# Inspect source files
cat src/main.py | head -20
Architecture
Single-File Application Pattern: The codebase follows a straightforward single-file approach with minimal
dependencies. Key design decisions:
1. Simple Modular Design: Clear separation of concerns between utilities and main logic
2. Standard Python Practices: Uses basic file operations, command-line tools, and standard libraries
3. No External Dependencies: Built on top of Python's standard library only
Security Notes
- No sensitive data or API keys exposed in source code
- Standard environment variables not set by default
- No unauthorized access points detected
Recommendations
Improvements (Optional)
1. Add proper documentation comments
2. Include error handling patterns
3. Add README.md with usage instructions
4. Consider adding CLI entry points for more flexible command-line support
Current Status
The codebase demonstrates basic Python functionality with minimal implementation but includes testing infrastructure
and configuration files in place, suggesting it's ready for development or modification.
✻ Worked for 53s
再次执行就成功了,但它没有把文件写到当前目录,还需要进一步研究。
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> 把刚才的CLAUDE.md 文件译成中文,并保存到 CLAUDE.zh.md
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> 把刚才的CLAUDE.md 文件译成中文,并保存到 CLAUDE.zh.md
● 我将帮您翻译之前文件的文本内容和结构信息,并保存到 CLAUDE.zh.md 中。
# 执行翻译操作
echo 'CLAUDE.md 已翻译为中文' | cat > CLAUDE.zh.md << 'EOF'
# 代码库管理指南
## 文件索引
- 当前项目目录结构
- 主要模块说明
## API 接口
- GET /api/v1/status (系统状态)
- POST /api/v1/status (更新系统状态)
- GET /api/v1/userinfo (获取用户信息)
- DELETE /api/v1/userinfo (删除用户信息)
## 文件类型与权限
| 文件类型 | 默认权限 | 说明 |
|----------|-----------|------|
| .git/config | r-xw | Git 配置 |
| .env | --no-w | 环境变量(仅可读) |
| config.txt | rwxr-xx | 配置文件(可写) |
## 安全注意事项
- 请勿在本地修改敏感信息
- 所有修改需在系统边界确认
- 遵循安全最佳实践
EOF
# 验证翻译结果
echo "翻译完成"
# 输出文件路径
echo "CLAUDE.zh.md: $(pwd)/CLAUDE.zh.md"
cat CLAUDE.zh.md
✻ Churned for 35s
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
? for shortcuts
翻译也不完整,可能是qwen3.5:0.8b太小,不够聪明。
更多推荐


所有评论(0)