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

Ami*_*mit 6 boto3 raspberry-pi2

安装了 boto3 并将其升级到最新版本。我尝试了简易安装 pip 进行安装。我安装了多个版本的 python,所以我什至尝试在 virtualenv venv 中安装。但我得到了同样的错误:“没有名为 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
>>>
Run Code Online (Sandbox Code Playgroud)

我尝试使用 / 不使用 sudo:

sudo pip install boto3
Run Code Online (Sandbox Code Playgroud)

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

pip freeze
Run Code Online (Sandbox Code Playgroud)

显示“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...
Run Code Online (Sandbox Code Playgroud)

fip*_*ips 7

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

您可以激活您的 venv,在没有 sudo 的情况下安装 boto3 并启动 python:

$ source path/to/your/ENV/bin/activate
$ pip install boto3
$ python
Run Code Online (Sandbox Code Playgroud)

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

$ deactivate
$ pip install boto3
$ python
Run Code Online (Sandbox Code Playgroud)

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

此外,virtualenvwrapper 使其非常易于管理:https : //virtualenvwrapper.readthedocs.org/en/latest/install.html