我正在尝试安装boto3,所以我可以在我的python脚本中使用它,我想在运行Ubuntu 14.04的EC2实例上运行它。无论如何我安装boto3它打破了非root用户的awscli安装。我使用apt get with sudo apt-get install awscli
安装awscli。安装后,它适用于root用户和ubuntu用户。
ubuntu@ip-10-12-10-8:~$ aws --version
aws-cli/1.14.65 Python/2.7.6 Linux/3.13.0-143-generic botocore/1.9.18
ubuntu@ip-10-12-10-8:~$ sudo aws --version
aws-cli/1.14.65 Python/2.7.6 Linux/3.13.0-143-generic botocore/1.9.18
我也尝试过安装awscli,就像AWS建议sudo pip install awscli --upgrade --user
一样。此外,如果它意味着任何pip只运行,因为root用户可能安装错误。
这是我用pip安装boto3时的输出。
但是无论何时我用pip安装boto3,它都会为ubuntu用户打破它。我试图安装boto3,然后以许多不同的方式安装awscli,没有任何作用。以下是我尝试过的方法。
ubuntu@ip-10-12-10-8:~$ sudo pip install boto3
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting boto3
/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/util/ssl_.py:339:
SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/util/ssl_.py:137:
InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
Downloading boto3-1.7.4-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 6.9MB/s
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in
/usr/local/lib/python2.7/dist-packages (from boto3)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.10 in
/usr/local/lib/python2.7/dist-packages (from boto3)
Collecting botocore<1.11.0,>=1.10.4 (from boto3)
Downloading botocore-1.10.4-py2.py3-none-any.whl (4.2MB)
100% |████████████████████████████████| 4.2MB 328kB/s
Requirement already satisfied: futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" in /usr/local/lib/python2.7/dist-packages (from s3transfer<0.2.0,>=0.1.10->boto3)
Requirement already satisfied: python-dateutil<2.7.0,>=2.1 in
/usr/local/lib/python2.7/dist-packages (from botocore<1.11.0,>=1.10.4->boto3)
Requirement already satisfied: docutils>=0.10 in /usr/local/lib/python2.7/dist-packages (from botocore<1.11.0,>=1.10.4->boto3)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python2.7/dist-packages (from python-dateutil<2.7.0,>=2.1->botocore<1.11.0,>=1.10.4->boto3)
Installing collected packages: botocore, boto3
Found existing installation: botocore 1.9.18
Uninstalling botocore-1.9.18:
Successfully uninstalled botocore-1.9.18
Successfully installed boto3-1.7.4 botocore-1.10.4
然后就是结果。我需要aws工具来处理两个用户,就像在boto3安装之前一样。
ubuntu@ip-10-12-10-8:~$ aws --version
Traceback (most recent call last):
File "/usr/local/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 17, in <module>
import botocore.session
ImportError: No module named botocore.session
ubuntu@ip-10-12-10-8:~$ sudo aws --version
aws-cli/1.14.65 Python/2.7.6 Linux/3.13.0-143-generic botocore/1.10.
发生了什么事?我一直在这里。
答案 0 :(得分:0)
这是我使用的,它还将安装awscli和具有自动完成功能的aws-shell。
$ sudo pip install aws-shell --upgrade --ignore-installed six
请告诉我这是否修复了boto3和awscli。
答案 1 :(得分:0)
如果您从未使用virtualenv,请立即执行此操作。
或者您可以使用conda,另一个python虚拟环境。
它会解决你的“问题”。
这是一个设计“问题”。然而,即使不使用AWSCLI,也必须学习为python应用程序设置python virtualenv,即使只有一个项目。
答案 2 :(得分:0)
awscli
维护者的响应是“除了安装pip
以外,请勿使用awscli
”。 https://github.com/aws/aws-cli/issues/2353#issuecomment-270492205
每两个注释将sudo
用于pip install
。这将起作用,但是如上所述sudo -H pip install somepackage
或可能更好的sudo -H -E pip install somepackage
应该安装它并在整个系统范围内可用。另一个选择是训练您的用户使用pip install --user awscli
,以便只有那些需要运行它的用户才可以使用它,并且恶意脚本/用户不能使用实例的IAM角色访问事物。
如果上述方法仍无法解决,则可能是一个极端的错误,即如果/tmp
与noexec
一起安装,则安装后的安装未正确标记aws
二进制文件具有+x
权限。您可以尝试运行python3 /usr/bin/aws
或python /usr/bin/aws
(也可能在/ usr / local / bin / aws中),然后查看是否返回了aws
命令的预期输出。
另一个答案中提到的另一种替代方法是将其安装到虚拟环境中,这是隔离事物的一种很好的方法,但是如果您不愿意在具有适当权限的情况下使其在系统范围内可用,则可能会很棘手。熟悉虚拟环境。