惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
M
MIT News - Artificial intelligence
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
The Register - Security
The Register - Security
S
SegmentFault 最新的问题
I
Intezer
Know Your Adversary
Know Your Adversary
T
Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
Security Latest
Security Latest
量子位
S
Securelist
Recorded Future
Recorded Future
V2EX - 技术
V2EX - 技术
Application and Cybersecurity Blog
Application and Cybersecurity Blog
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
P
Privacy International News Feed
AI
AI
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
博客园_首页
IT之家
IT之家
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
C
CERT Recently Published Vulnerability Notes
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The GitHub Blog
The GitHub Blog
美团技术团队
L
LangChain Blog
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security Affairs
Cloudbric
Cloudbric
O
OpenAI News
PCI Perspectives
PCI Perspectives
J
Java Code Geeks
P
Privacy & Cybersecurity Law Blog
B
Blog RSS Feed
MyScale Blog
MyScale Blog

博客园 - 三瑞

OpenClaw 能检测到浏览器,却弹不出窗口?Ubuntu 24.04 问题全复盘与终极解决 问题现象 idea 安装cline openclaw 允许局域网能访问 VirtualBox 共享文件夹配置指南(Ubuntu 24.04 不重启方案) Nginx+Bearer Key 保护 Ollama + OpenClaw 远程连接 ubuntu24.04 安装 vscode Ubuntu 24.04 安装 KVM 完整指南 Ubuntu 启动卡顿 2 分钟?一条命令解决 Linux下Ollama + AMD ROCm GPU加速安装实操指南 Ubuntu 24.04 挂载第二块磁盘并扩展 LVM 系统盘 openclaw qqbot 反复提示 ubuntu 终端代理设置 干货|xrdp 无人值守+同屏稳定配置(Ubuntu 22.04/24.04 实测可用) openclaw 使用不同的模型 AMD GPU (RX 7900 XTX) 使用情况查看 Ubuntu 24.04 自带GNOME RDP远程连不上?一招解决xrdp残留冲突问题 Ubuntu 24.04 磁盘空间管理:从查看到 LVM 动态扩容完整指南 避坑指南完整版:OpenClaw 连接 Ollama 详细实战教程 干货|Ubuntu 24.04 + AMD 7900 XTX 24G:Ollama 纯 Vulkan 加速部署(免 ROCm) Windows 连接 Ubuntu XRDP 远程桌面 QQ机器人接入OpenClaw完整指南:从零开始打造你的智能助手 VirtualBox U盘识别问题完美解决指南 ——记一次从入门到放弃再到入门的折腾历程 Ubuntu 系统 root 密码忘记怎么办?一招教你轻松重置 VirtualBox Ubuntu 虚拟机安装增强功能完整指南 HTTP 错误 500.21 - Internal Server Error 处理程序“BlockViewHandler”在其模块列表中有一个错误模块“ManagedPipelineHandler” 达梦数据库(DM)通过数据库类型生成修改字段类型的语句
python3 在vscode 中调试
三瑞 · 2026-07-09 · via 博客园 - 三瑞

一、先拿到虚拟环境绝对完整路径(必须先做)

source ollama-ocr-env/bin/activate
# 打印完整绝对路径
which python3
# 或者更稳妥
python3 -c "import sys; print(sys.executable)"

输出示例(复制这一整串):

/home/xxx/project/ollama-ocr-env/bin/python3

二、VSCode 手动指定解释器(列表搜不到就用这个)

  1. 快捷键 Ctrl+Shift+P 调出命令面板
  2. 输入:Python: Select Interpreter 回车
  3. 拉到列表最底部,点 Enter interpreter path...
  4. 选择 Find... 浏览文件,或者直接粘贴刚才复制的完整路径 /xxx/ollama-ocr-env/bin/python3
  5. 确认后左下角状态栏就会显示 ollama-ocr-env 环境

三、永久固定环境(不用每次重新选)

项目文件夹里新建 .vscode/settings.json,写入刚才的绝对路径:

{
    "python.defaultInterpreterPath": "/home/xxx/project/ollama-ocr-env/bin/python3"
}

四、调试配置 launch.json(对应你运行命令:python3 ocr_service.py)

.vscode/launch.json 完整配置,支持终端交互、和手动运行完全一致:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "调试ocr_service",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/ocr_service.py",
            "console": "integratedTerminal",
            "cwd": "${workspaceFolder}"
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Flask OCR Service",
            "type": "debugpy",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "ocr_service.py",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "1"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload",
                "--host",
                "0.0.0.0",
                "--port",
                "5000"
            ],
            "jinja": true,
            "justMyCode": false,
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Debug Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}
  • integratedTerminal:内置终端,支持input()输入
  • cwd:工作目录和你手动执行命令一致

五、启动调试

  1. 打开 ocr_service.py,代码左侧点击空白处打红色断点
  2. 顶部调试下拉框选择「调试 ocr_service」
  3. F5 开始调试

六、常见排查

  1. 粘贴路径提示找不到文件 检查路径是否复制完整、大小写、文件夹权限:chmod +x ollama-ocr-env/bin/python3
  2. 导入 ollama 模块报错 确认左下角解释器是 ollama-ocr-env,不是系统 python
  3. 断点灰色无效 重启 VSCode、重新选中解释器、重装 Python 扩展