简体   繁体   English

Visual Studio 导入错误:没有名为 boto3 的模块

[英]Visual Studio ImportError: No module named boto3

I am trying to run VS-Code to work with Python and boto3.我正在尝试运行 VS-Code 以使用 Python 和 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 运行 python 语句,但由于某种原因,我无法让它与 AWS 一起使用。

VS-Code Extension: VS 代码扩展:

AWS Toolkit 
Code Runner 
Python 

MacOS CLI macOS 命令行界面

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 VS-Code launch.json

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

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).消失了(在关闭并重新打开我正在编辑的 Python 文件之后)。

Background :背景
I am new to VisualStudio Code (Version: 1.41.1 on MacOS Mojave 10.14.6) and I was having the same problem.我是 VisualStudio Code 的新手(MacOS Mojave 10.14.6 上的版本:1.41.1),我遇到了同样的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM