python - Mac OS 上导入 boto3 错误

标签 python python-3.x pip aws-sdk boto3

我正在尝试在我的 mac(high Sierra 10.13.3)上安装 boto3 并尝试遵循:https://github.com/boto/boto3 。我之前已经使用 homebrew 安装了 python 3,但是当我尝试查看 pip --version 时,出现错误。 所以,我做到了

1)修改.bash_profile添加

alias pip=pip3

2)验证

$ pip --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

3)

$ pip install boto3
Collecting boto3
  Downloading boto3-1.5.36-py2.py3-none-any.whl (128kB)
    100% |████████████████████████████████| 133kB 474kB/s
Collecting botocore<1.9.0,>=1.8.50 (from boto3)
  Downloading botocore-1.8.50-py2.py3-none-any.whl (4.1MB)
    100% |████████████████████████████████| 4.1MB 376kB/s
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in ./Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: docutils>=0.10 in ./Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in ./Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)
Installing collected packages: botocore, boto3
  Found existing installation: botocore 1.8.20
    Uninstalling botocore-1.8.20:
      Successfully uninstalled botocore-1.8.20
Successfully installed boto3-1.5.36 botocore-1.8.50

4)只是为了确保这没问题,我跑了

$ pip3 install boto3
Requirement already satisfied: boto3 in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from boto3)
Requirement already satisfied: botocore<1.9.0,>=1.8.50 in /usr/local/lib/python3.6/site-packages (from boto3)
Requirement already satisfied: docutils>=0.10 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from botocore<1.9.0,>=1.8.50->boto3)
Requirement already satisfied: six>=1.5 in /Users/ond983/Library/Python/3.6/lib/python/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.50->boto3)

5) 但是,现在当我在 Idle 中运行 import boto3 时,出现错误

import boto3
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import boto3
ModuleNotFoundError: No module named 'boto3'

我什至尝试更改.bash_profile中的路径,但它不起作用。 想法?

最佳答案

对我来说,只需将名称中包含“bolo”的所有包从 Python 3.7 文件夹复制到 Python 2.7 文件夹即可:

/usr/local/lib/python3.7/site-packages $ sudo cp -R boto* /Library/Python/2.7/site-packages/.

关于python - Mac OS 上导入 boto3 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48958745/

相关文章:

python - 如何基于 CSV 文件创建字典

python - 如何在 Python 3 的 dateutil 解析器中解析超过 24 小时的日期?

python - 将 JSON 写入文件而不将转义反斜杠写入文件?

python - PermissionError (WinError 31) 连接到系统的设备无法运行

python-3.x - setup.py 与 conda 安装的依赖项(不是 pip)

python - 在子图中绘制平均线

python - Keras 访问自定义损失函数中的各个值

python - 错误 "resolve() got an unexpected keyword argument ' Replace_conflicting'"是什么意思?

python - 为什么我的 python 打印比 Go 的 fmt.Print 和 os.Stdout.Write 运行得更快

ssl - 使用 pip 安装证书验证失败,主要问题,(_ssl.c :1108)