在Mac OS上导入boto3错误

时间:2018-02-24 02:30:07

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

我试图在我的mac(high sierra 10.13.3)上安装boto3并尝试关注:https://github.com/boto/boto3。我之前已经使用自制软件安装了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)但是,现在当我在空闲时运行导入boto3时,我收到错误

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

我甚至试图改变.bash_profile中的路径,但它没有用。 想法?

1 个答案:

答案 0 :(得分:0)

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

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