简体   繁体   English

“导入错误:没有名为 boto3 的模块”在 Mac 上

[英]“ImportError: No module named boto3” on mac

I am trying a deployment script, which will need to import boto3, when I run the script, it give me error message:我正在尝试一个部署脚本,它需要导入 boto3,当我运行脚本时,它给了我错误消息:

ImportError: No module named boto3

then I ran:然后我跑了:

pip install boto3

it returns:它返回:

Requirement already satisfied: boto3 in /usr/local/lib/python3.7/site-packages (1.9.228)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.9.4)
Requirement already satisfied: s3transfer<0.3.0,>=0.2.0 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.2.1)
Requirement already satisfied: botocore<1.13.0,>=1.12.228 in /usr/local/lib/python3.7/site-packages (from boto3) (1.12.228)
Requirement already satisfied: docutils<0.16,>=0.10 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (0.14)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1; python_version >= "2.7" in /usr/local/lib/python3.7/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (2.8.0)
Requirement already satisfied: urllib3<1.26,>=1.20; python_version >= "3.4" in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (1.25.3)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore<1.13.0,>=1.12.228->boto3) (1.12.0)

I ran pip3 install boto3 , still it gave the same output as above.我运行了pip3 install boto3 ,它仍然给出了与上面相同的输出。

then I ran the deployment script, the same errors with complaining然后我运行了部署脚本,抱怨同样的错误

ImportError: No module named boto3

Any ideas where goes wrong?任何想法哪里出了问题?

I'm using mac 10.14.6 version.我使用的是 mac 10.14.6 版本。

Requirement already satisfied: boto3 in /usr/local/lib/python3.7/site-packages (1.9.228) Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.9.4)已满足要求:/usr/local/lib/python3.7/site-packages (1.9.228) 中的boto3 已满足要求:/Users/xiaoyiliu/Library/Python/ 中的jmespath<1.0.0,>=0.7.1 3.7/lib/python/site-packages(来自 boto3)(0.9.4)

Make sure that /usr/local/lib/python3.7/site-packages and /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages are in the path.确保/usr/local/lib/python3.7/site-packages/Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages在路径中。

Use the below code to temporarily append it to the path.:使用以下代码将其temporarily附加到路径。:

import sys
print(sys.path)
sys.path.append('/usr/local/lib/python3.7/site-packages')
sys.path.append('/Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages')
print(sys.path)

import boto3

I am trying a deployment script, which will need to import boto3, when I run the script, it give me error message:我正在尝试部署脚本,该脚本需要导入boto3,当我运行脚本时,它会显示错误消息:

ImportError: No module named boto3

then I ran:然后我跑了:

pip install boto3

it returns:它返回:

Requirement already satisfied: boto3 in /usr/local/lib/python3.7/site-packages (1.9.228)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.9.4)
Requirement already satisfied: s3transfer<0.3.0,>=0.2.0 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.2.1)
Requirement already satisfied: botocore<1.13.0,>=1.12.228 in /usr/local/lib/python3.7/site-packages (from boto3) (1.12.228)
Requirement already satisfied: docutils<0.16,>=0.10 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (0.14)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1; python_version >= "2.7" in /usr/local/lib/python3.7/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (2.8.0)
Requirement already satisfied: urllib3<1.26,>=1.20; python_version >= "3.4" in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (1.25.3)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore<1.13.0,>=1.12.228->boto3) (1.12.0)

I ran pip3 install boto3 , still it gave the same output as above.我运行了pip3 install boto3 ,它仍然提供了与上述相同的输出。

then I ran the deployment script, the same errors with complaining然后我运行部署脚本,抱怨同样的错误

ImportError: No module named boto3

Any ideas where goes wrong?任何想法哪里出了问题?

I'm using mac 10.14.6 version.我正在使用mac 10.14.6版本。

Make sure you have installed your package with the pip associated with a particular python, use:确保您已经使用与特定 python 关联的 pip 安装了您的包,使用:

python -m pip install <pkg>

instead of:代替:

pip install <pkg>

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

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