【发布时间】:2018-09-20 21:04:14
【问题描述】:
我正在尝试安装 boto3,以便可以在我想要在运行 Ubuntu 14.04 的 EC2 实例上运行的 python 脚本中使用它。无论如何,我安装 boto3 它会破坏我在非 root 用户上安装 awscli。我使用带有sudo apt-get install awscli 的apt get 安装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
我也尝试过安装 AWS 建议的 sudo pip install awscli --upgrade --user 的 awscli。此外,如果这意味着任何 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.
发生了什么事?我一直在这。
【问题讨论】:
-
如果再次安装 awscli 会怎样?
-
还是不行。给出同样的错误。
-
试试这个:
sudo pip install awscli --force-reinstall --upgrade -
我已经从另一个 SO 帖子中尝试过这个命令。这导致 aws 也只能在 sudo 用户上工作。
-
sudo -H pip怎么样。它为所有用户安装。