ImportError: No module named boto3

ImportError: No module named boto3

安装了 boto3 并将其升级到最新版本。我尝试了 easy install pip 进行安装。我安装了 python 的多个版本,所以我什至尝试在 virtualenv venv 中安装。但是我得到了同样的错误:"No module named boto3".

pip install boto3

python
Python 2.7.11 (default, Mar 10 2016, 14:12:44)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named boto3
>>>

我试过有/没有 sudo:

sudo pip install boto3

我正在尝试在 Raspberry Pi 上安装 AWS SDK。

pip freeze

显示已安装 "boto3==1.3.0"。

sudo pip install boto3

Requirement already satisfied (use --upgrade to upgrade): boto3 in    /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): botocore>=1.4.1, <1.5.0 in /usr/local/lib/python2.7/dist-packages (from boto3)
Requirement already satisfied (use --upgrade to upgrade): jmespath>=0.7.1,<1.0.0 in /usr/local/lib/python2.7/dist-packages (from boto3)
Requirement already satisfied (use --upgrade to upgrade): futures>=2.2.0,<4.0.0 in /usr/local/lib/python2.7/dist-packages (from boto3)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil>=2.1,<3.0.0 in /usr/local/lib/python2.7/dist-packages (from botocore>=1.4.1,<1.5.0->boto3)
Requirement already satisfied (use --upgrade to upgrade): docutils>=0.10 in /usr/local/lib/python2.7/dist-packages (from botocore>=1.4.1,<1.5.0->boto3)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /usr/local/lib/python2.7/dist-packages (from python-dateutil>=2.1,<3.0.0->botocore>=1.4.1,<1.5.0->boto3)
Cleaning up...

sudo pip install boto3 将其安装到您的全局 pip。此处解释:

您可以激活您的 venv,安装 boto3 无需 sudo 并启动 python:

$ source path/to/your/ENV/bin/activate
$ pip install boto3
$ python

或者,如果您更喜欢使用全局安装,请执行以下操作:

$ deactivate
$ pip install boto3
$ python

查看 virtualenv 用户指南:https://virtualenv.pypa.io/en/latest/userguide.html

virtualenvwrapper 也让它变得非常容易管理: https://virtualenvwrapper.readthedocs.org/en/latest/install.html

我的 mac 在全球范围内有效

sudo pip install --ignore-installed six boto3

我遇到了同样的问题,也没有使用虚拟环境。 easy_install 正在为我工​​作。我正在使用 Ubuntu 16.04,我的 python 版本是 2.7

easy_install boto3

尝试激活您的虚拟环境

source bin/activate

然后尝试连接安装boto3

pip install boto3

有时还需要botocore,所以安装boto3和botocore。