由于模块colorama,无法使用aws CLI

Gro*_*ler 5 python amazon-web-services colorama

我已经安装了AWS CLI,并尝试在Mac OS Sierra上使用它.它抱怨没有模块colorama:

$ aws

Traceback (most recent call last):
  File "/usr/local/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 26, in <module>
    from awscli.formatter import get_formatter
  File "/Library/Python/2.7/site-packages/awscli/formatter.py", line 19, in <module>
    from awscli.table import MultiTable, Styler, ColorizedStyler
  File "/Library/Python/2.7/site-packages/awscli/table.py", line 18, in <module>
    import colorama
ImportError: No module named colorama
Run Code Online (Sandbox Code Playgroud)

所以我尝试安装它,它说已满足要求:

$ sudo pip install colorama

The directory '/Users/danniu/Library/Caches/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 '/Users/danniu/Library/Caches/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.
Requirement already satisfied: colorama in /Users/danniu/Library/Python/2.7/lib/python/site-packages
Run Code Online (Sandbox Code Playgroud)

Jul*_*ien 8

不要安装Python模块sudo.如果添加--user命令行选项,则会将程序包安装到您的主文件夹(您的用户拥有)中,您无需使用sudo.

如果您希望这是默认值,则可以pip.conf使用以下内容创建文件:

[install]
user = true
Run Code Online (Sandbox Code Playgroud)

位于您给定的操作系统上的位置(在它位于的macOS Sierra上$HOME/Library/Application Support/pip/pip.conf).

解决问题最简单的方法就是运行

$ pip install --upgrade --user awscli
Run Code Online (Sandbox Code Playgroud)

因为这将确保您拥有所有需要的依赖项.