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

使用Moto模拟AWS Lambda时出现ModuleNotFoundError: No module named 'docker'的解决咨询

Fixing "ModuleNotFoundError: No module named 'docker'" When Using Moto to Mock AWS Lambda

That error pops up because Moto's Lambda mocking functionality relies on the Docker Python SDK to interact with your local Docker service—even though you've started Docker, the required Python package isn't installed yet. Here's how to fix it:

Step 1: Install the Docker Python SDK

Run this command in your terminal (make sure you're in your project's virtual environment if you're using one):

pip install docker

If you manage dependencies with a requirements.txt file, add docker to the list and run pip install -r requirements.txt instead.

Step 2: Verify Docker is running correctly

Even though you said you started Docker, double-check to ensure the service is active. Run this command in your terminal:

docker ps

If you see a list of running containers (or an empty list if none are running), Docker is working properly. If you get an error, restart your Docker service and try again.

Optional: Check for version compatibility

In rare cases, newer versions of the Docker SDK might have compatibility issues with older Moto versions. If you still run into problems after installing the SDK, try installing a specific version that's known to work with your Moto version. For example:

pip install docker==6.1.3

Quick note on your test code

I noticed a small typo in your test: you're calling get_auth("arn", "input_str") but your business function is named get_lambda_resp. Fixing that will help avoid additional errors once the Docker issue is resolved.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 10:43:14