You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VSCode中使用AWS Toolkit调试Python Lambda函数时遇到debugpy依赖解析失败问题求助

Troubleshooting debugpy Dependency Error in AWS Toolkit Python Lambda Debugging

Hey there! Let's get this sorted out for you—since you're new to Python Lambda, I'll start with a quick breakdown of what's going on, then walk you through actionable fixes.

First, what is debugpy?

debugpy is the Python debugging tool that AWS Toolkit uses to run and debug your Lambda functions locally. Think of it as the equivalent of the debugging tools you relied on for Node.js Lambda—it lets VS Code attach a debugger to your running Python function so you can step through code.

Why are you seeing this error?

The error PythonPipBuilder:ResolveDependencies - {debugpy==1.5.0(wheel)} means the SAM CLI (which AWS Toolkit uses under the hood) can't install the debugpy==1.5.0 package when building your Lambda environment. This usually stems from version mismatches, network issues, or corrupted cached build files.

Step-by-step fixes to try:

  1. Match your local Python version to Lambda's runtime
    Lambda supports specific Python versions (like 3.8, 3.9, 3.10). If your local Python version is too different from what you've set for your Lambda, debugpy might fail to install. Check your local version with:

    python --version
    # Or python3 --version on macOS/Linux
    

    Make sure this matches the runtime defined in your template.yaml (e.g., runtime: python3.9).

  2. Manually specify a compatible debugpy version in requirements.txt
    AWS Toolkit automatically adds debugpy to your dependencies during debugging, but the default 1.5.0 version might not play nice with your setup. Add this line to your requirements.txt to force a more compatible version:

    debugpy>=1.6.0
    

    This tells SAM to install a newer, more widely supported release of debugpy.

  3. Clear AWS Toolkit's build cache
    Temporary build files can get corrupted over time. Delete the cached directory mentioned in your error:

    C:/path_to_user/AppData/Local/Temp/aws-toolkit-vscode/vsctkYP3zOS/
    

    Then try running the debugger again—SAM will rebuild the environment from scratch, which often fixes weird dependency glitches.

  4. Update AWS Toolkit and SAM CLI
    Outdated versions of the toolkit or SAM CLI can cause dependency resolution bugs:

    • In VS Code, go to the Extensions tab, find AWS Toolkit, and click "Update".
    • Update SAM CLI by running pip install --upgrade aws-sam-cli (works on most systems).
  5. Install debugpy locally first
    Try installing the problematic version directly in your local Python environment to rule out installation issues:

    pip install debugpy==1.5.0
    

    If this fails, it might point to a network problem (like blocked access to PyPI). In that case, configure a PyPI mirror (e.g., a regional mirror) via a pip.conf (Linux/macOS) or pip.ini (Windows) file to bypass restrictions.

Bonus tip: Use a virtual environment

For Python projects, always use a virtual environment to isolate dependencies and avoid conflicts with global packages. Create one with:

python -m venv .venv
# Activate it:
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate

内容的提问来源于stack exchange,提问作者MountainBiker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 18:07:31