我正在尝试部署脚本,该脚本需要导入boto3,当我运行脚本时,它会显示错误消息:
ImportError: No module named boto3
然后我跑了
pip install boto3
它返回:
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)
我运行了pip3 install boto3
,但仍给出了与上面相同的输出。
然后我运行部署脚本,与抱怨相同的错误
ImportError: No module named boto3
任何想法哪里出问题了?
我正在使用mac 10.14.6版本。
答案 0 :(得分:0)
已满足要求:/usr/local/lib/python3.7/site-packages(1.9.228)中的boto3 已经满足的要求:/Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages中的jmespath <1.0.0,> = 0.7.1(来自boto3)(0.9.4)
确保/usr/local/lib/python3.7/site-packages
和/Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages
在路径中。
使用以下代码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