AWS CLIのバージョンをアップグレードしたらエラーがでて使えなくなったので確認した内容を書いておきます。
AWS CLIの最新バージョンをインストール
pip で--upgrade
または-U
オプションを付けて最新版をインストールします。
$ sudo pip install --upgrade awscli
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
Downloading/unpacking awscli from https://pypi.python.org/packages/source/a/awscli/awscli-1.6.8.tar.gz#md5=08fa73eb1010e34a03dd820e14ff4fee
Downloading awscli-1.6.8.tar.gz (280kB): 280kB downloaded
Running setup.py (path:/private/tmp/pip_build_root/awscli/setup.py) egg_info for package awscli
Downloading/unpacking botocore>=0.78.0,<0.79.0 (from awscli)
Downloading botocore-0.78.0.tar.gz (1.2MB): 1.2MB downloaded
Running setup.py (path:/private/tmp/pip_build_root/botocore/setup.py) egg_info for package botocore
Requirement already up-to-date: bcdoc>=0.12.0,<0.13.0 in /Library/Python/2.7/site-packages (from awscli)
Downloading/unpacking six>=1.8.0,<2.0.0 (from awscli)
Downloading six-1.8.0-py2.py3-none-any.whl
Requirement already up-to-date: colorama==0.2.5 in /Library/Python/2.7/site-packages (from awscli)
Requirement already up-to-date: docutils>=0.10 in /Library/Python/2.7/site-packages (from awscli)
Requirement already up-to-date: rsa==3.1.2 in /Library/Python/2.7/site-packages (from awscli)
Downloading/unpacking jmespath==0.5.0 (from botocore>=0.78.0,<0.79.0->awscli)
Downloading jmespath-0.5.0.tar.gz
Running setup.py (path:/private/tmp/pip_build_root/jmespath/setup.py) egg_info for package jmespath
Downloading/unpacking python-dateutil>=2.1,<3.0.0 (from botocore>=0.78.0,<0.79.0->awscli)
Downloading python_dateutil-2.3-py2.py3-none-any.whl (173kB): 173kB downloaded
Requirement already up-to-date: pyasn1>=0.1.3 in /Library/Python/2.7/site-packages (from rsa==3.1.2->awscli)
Installing collected packages: awscli, botocore, six, jmespath, python-dateutil
Found existing installation: awscli 1.5.2
Uninstalling awscli:
Successfully uninstalled awscli
Running setup.py install for awscli
changing mode of build/scripts-2.7/aws from 644 to 755
changing mode of build/scripts-2.7/aws.cmd from 644 to 755
changing mode of build/scripts-2.7/aws_completer from 644 to 755
changing mode of build/scripts-2.7/aws_zsh_completer.sh from 644 to 755
changing mode of /usr/local/bin/aws to 755
changing mode of /usr/local/bin/aws.cmd to 755
changing mode of /usr/local/bin/aws_completer to 755
changing mode of /usr/local/bin/aws_zsh_completer.sh to 755
Found existing installation: botocore 0.66.0
Uninstalling botocore:
Successfully uninstalled botocore
Running setup.py install for botocore
Found existing installation: six 1.4.1
Uninstalling six:
Successfully uninstalled six
Found existing installation: jmespath 0.4.1
Uninstalling jmespath:
Successfully uninstalled jmespath
Running setup.py install for jmespath
changing mode of build/scripts-2.7/jp from 644 to 755
changing mode of /usr/local/bin/jp to 755
Found existing installation: python-dateutil 1.5
Uninstalling python-dateutil:
Successfully uninstalled python-dateutil
Successfully installed awscli botocore six jmespath python-dateutil
Cleaning up...
メッセージでは完了してたのでバージョンを確認しようとしたらエラーが出ました。
$ aws --version Traceback (most recent call last): File "/usr/local/bin/aws", line 23, in <module> sys.exit(main()) File "/usr/local/bin/aws", line 19, in main return awscli.clidriver.main() File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 49, in main driver = create_clidriver() File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 58, in create_clidriver event_hooks=emitter) File "/Library/Python/2.7/site-packages/awscli/plugin.py", line 44, in load_plugins modules = _import_plugins(plugin_mapping) File "/Library/Python/2.7/site-packages/awscli/plugin.py", line 61, in _import_plugins module = __import__(path, fromlist=[module]) File "/Library/Python/2.7/site-packages/awscli/handlers.py", line 61, in <module> from awscli.customizations.opsworks import initialize as opsworks_init File "/Library/Python/2.7/site-packages/awscli/customizations/opsworks.py", line 24, in <module> from six.moves import shlex_quote ImportError: cannot import name shlex_quote
エラーの原因
情報が無さすぎてわからなかったのですがGitHubのissuesに同じ話題があったので、英語が読めないながら確認してみるとImportError: cannot import name shlex_quote
とあるように shlex_quote が無いと言ってます。この shlex_quote は six というパッケージのバージョン1.8から追加されてるようで、AWS CLIのバージョン1.6.7から必要になったみたいです。
インストールした時のログを見ても six1.8 がインストールされてるように見えるので、バージョンを確認してみるとちゃんと1.8 になってます。
$ pip show six --- Name: six Version: 1.8.0 Location: /Library/Python/2.7/site-packages
しかし issues のコメントにあるもう一つの方法で試すと、こっちは 1.4.1 になってました。どうやらこれが原因みたいです。file の参照先を見ても、上記の1.8とは違うところを見てますね。これどうやって変えればいいんでしょう...?
$ python Python 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import six >>> print six.__version__ 1.4.1 >>> print(six.__file__) /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc >>> exit()
暫定対処
結局この問題を解消する術がわからなかったのでとりあえず 1.6.6 をインストールすることにしました。このバージョンなら six 1.8 じゃなくても大丈夫です。
$ sudo pip install awscli==1.6.6 Downloading/unpacking awscli==1.6.6 Downloading awscli-1.6.6.tar.gz (274kB): 274kB downloaded Running setup.py (path:/private/tmp/pip_build_root/awscli/setup.py) egg_info for package awscli Downloading/unpacking botocore>=0.77.0,<0.78.0 (from awscli==1.6.6) Downloading botocore-0.77.0.tar.gz (1.2MB): 1.2MB downloaded Running setup.py (path:/private/tmp/pip_build_root/botocore/setup.py) egg_info for package botocore Requirement already satisfied (use --upgrade to upgrade): bcdoc>=0.12.0,<0.13.0 in /Library/Python/2.7/site-packages (from awscli==1.6.6) Requirement already satisfied (use --upgrade to upgrade): six>=1.1.0 in /Library/Python/2.7/site-packages (from awscli==1.6.6) Requirement already satisfied (use --upgrade to upgrade): colorama==0.2.5 in /Library/Python/2.7/site-packages (from awscli==1.6.6) Requirement already satisfied (use --upgrade to upgrade): docutils>=0.10 in /Library/Python/2.7/site-packages (from awscli==1.6.6) Requirement already satisfied (use --upgrade to upgrade): rsa==3.1.2 in /Library/Python/2.7/site-packages (from awscli==1.6.6) Requirement already satisfied (use --upgrade to upgrade): jmespath==0.5.0 in /Library/Python/2.7/site-packages (from botocore>=0.77.0,<0.78.0->awscli==1.6.6) Requirement already satisfied (use --upgrade to upgrade): python-dateutil>=2.1,<3.0.0 in /Library/Python/2.7/site-packages (from botocore>=0.77.0,<0.78.0->awscli==1.6.6) Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.3 in /Library/Python/2.7/site-packages (from rsa==3.1.2->awscli==1.6.6) Installing collected packages: awscli, botocore Found existing installation: awscli 1.6.8 Uninstalling awscli: Successfully uninstalled awscli Running setup.py install for awscli changing mode of build/scripts-2.7/aws from 644 to 755 changing mode of build/scripts-2.7/aws.cmd from 644 to 755 changing mode of build/scripts-2.7/aws_completer from 644 to 755 changing mode of build/scripts-2.7/aws_zsh_completer.sh from 644 to 755 changing mode of /usr/local/bin/aws to 755 changing mode of /usr/local/bin/aws.cmd to 755 changing mode of /usr/local/bin/aws_completer to 755 changing mode of /usr/local/bin/aws_zsh_completer.sh to 755 Found existing installation: botocore 0.78.0 Uninstalling botocore: Successfully uninstalled botocore Running setup.py install for botocore Successfully installed awscli botocore Cleaning up...
無事完了しました。
$ aws --version aws-cli/1.6.6 Python/2.7.6 Darwin/14.0.0
追記 (12/13)
AWS CLI 1.6.9 がリリースされてアップグレードしたら直りました。
$ sudo pip install --upgrade awscli Password: Downloading/unpacking awscli from https://pypi.python.org/packages/source/a/awscli/awscli-1.6.9.tar.gz#md5=2d52bb33700f69e842b4e35f1794b5f6 Downloading awscli-1.6.9.tar.gz (280kB): 280kB downloaded Running setup.py (path:/private/tmp/pip_build_root/awscli/setup.py) egg_info for package awscli Downloading/unpacking botocore>=0.79.0,<0.80.0 (from awscli) Downloading botocore-0.79.0.tar.gz (1.2MB): 1.2MB downloaded Running setup.py (path:/private/tmp/pip_build_root/botocore/setup.py) egg_info for package botocore ... ... Successfully installed awscli botocore Cleaning up...
$ aws --version aws-cli/1.6.9 Python/2.7.6 Darwin/14.0.0