首页 > 解决方案 > Visual Studio ImportError: No module named boto3

问题描述

I am trying to run VS-Code to work with Python and boto3. but I am getting the following error

importError: No module named boto3

I am able to run python statements via VS-code but for some reason I can't get it to work with AWS.

VS-Code Extension:

AWS Toolkit 
Code Runner 
Python 

MacOS CLI

python3 --version
Python 3.7.4
aws --version
aws-cli/1.16.209 Python/3.7.4 Darwin/18.0.0 botocore/1.12.199
pip3 --version
pip 19.2.1 

VS-Code launch.json

        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }

标签: pythonvisual-studioaws-cli

解决方案


Solution:
I opened a Terminal from the top menu (Terminal -> New Terminal);

in the newly opened terminal I typed:

pip install botocore
pip install boto3

After doing this, the errors I was getting for:

import boto3
from botocore.exceptions import ClientError

disappeared (after closing and reopening the Python file I was editing).

Background:
I am new to VisualStudio Code (Version: 1.41.1 on MacOS Mojave 10.14.6) and I was having the same problem.


推荐阅读