LoginSignup
6
4

More than 5 years have passed since last update.

AWS CLIのアップデートでハマった話と解決方法

Last updated at Posted at 2015-09-16

「そういえば AWS CLI のアップデートしてないなぁ」こんな風に思いたってアップデートをしてみました。
そしたらうっかりハマってしまうことに...

※環境:CentOS release 6.6 (Final) on IIJ GIO


まずは普通にアップデートを実行...

[ore@server ~]$ sudo pip install --upgrade awscli
Collecting awscli from https://pypi.python.org/packages/py2.py3/a/awscli/awscli-1.8.4-py2.py3-none-any.whl#md5=f7a52bd35ff7ed1b8eede7cb82049f39
  Downloading awscli-1.8.4-py2.py3-none-any.whl (769kB)
    100% |################################| 770kB 3.5MB/s
Requirement already up-to-date: colorama<=0.3.3,>=0.2.5 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: docutils>=0.10 in /usr/lib/python2.6/site-packages (from awscli)
Collecting argparse>=1.1 from https://pypi.python.org/packages/2.7/a/argparse/argparse-1.4.0-py2.py3-none-any.whl#md5=c37216a954c8669054e2b2c54853dd49 (from awscli)
  Downloading argparse-1.4.0-py2.py3-none-any.whl
Requirement already up-to-date: rsa<=3.1.4,>=3.1.2 in /usr/lib/python2.6/site-packages (from awscli)
Collecting botocore==1.2.2 (from awscli)
  Downloading botocore-1.2.2-py2.py3-none-any.whl (1.8MB)
    100% |################################| 1.8MB 3.0MB/s
Requirement already up-to-date: pyasn1>=0.1.3 in /usr/lib/python2.6/site-packages (from rsa<=3.1.4,>=3.1.2->awscli)
Collecting ordereddict==1.1 (from botocore==1.2.2->awscli)
  Downloading ordereddict-1.1.tar.gz
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help
    error: invalid command 'egg_info'
    Complete output from command python setup.py egg_info:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

       or: -c --help [cmd1 cmd2 ...]

       or: -c --help-commands

       or: -c cmd --help



    error: invalid command 'egg_info'

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-dBji6C/ordereddict

「あれ、エラーかぁ」ということで解消方法をネットで調べてみることに。
「なるほど、setuptoolsって言うのをアップデートすればよいのね」なんて余裕をかましてアップデートを実施。(※参考1)

[ore@server ~]$ sudo pip install --upgrade setuptools
Collecting setuptools from https://pypi.python.org/packages/3.4/s/setuptools/setuptools-18.3.1-py2.py3-none-any.whl#md5=a21a4d02d0bab2eac499cca72faeb076
  Downloading setuptools-18.3.1-py2.py3-none-any.whl (462kB)
    100% |################################| 462kB 1.5MB/s
Installing collected packages: setuptools
  Found existing installation: setuptools 0.6rc11
    Can't uninstall 'setuptools'. No files were found to uninstall.

Successfully installed setuptools-0.6rc11

setuptoolsアップデート完了後、もう一回aws cliのアップデートをしてみると...

[ore@server ~]$ sudo pip install --upgrade awscli
Collecting awscli from https://pypi.python.org/packages/py2.py3/a/awscli/awscli-1.8.4-py2.py3-none-any.whl#md5=f7a52bd35ff7ed1b8eede7cb82049f39
  Using cached awscli-1.8.4-py2.py3-none-any.whl
Requirement already up-to-date: colorama<=0.3.3,>=0.2.5 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: docutils>=0.10 in /usr/lib/python2.6/site-packages (from awscli)
Collecting argparse>=1.1 from https://pypi.python.org/packages/2.7/a/argparse/argparse-1.4.0-py2.py3-none-any.whl#md5=c37216a954c8669054e2b2c54853dd49 (from awscli)
  Using cached argparse-1.4.0-py2.py3-none-any.whl
Requirement already up-to-date: rsa<=3.1.4,>=3.1.2 in /usr/lib/python2.6/site-packages (from awscli)
Collecting botocore==1.2.2 (from awscli)
  Using cached botocore-1.2.2-py2.py3-none-any.whl
Requirement already up-to-date: pyasn1>=0.1.3 in /usr/lib/python2.6/site-packages (from rsa<=3.1.4,>=3.1.2->awscli)
Collecting ordereddict==1.1 (from botocore==1.2.2->awscli)
  Using cached ordereddict-1.1.tar.gz
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help
    error: invalid command 'egg_info'
    Complete output from command python setup.py egg_info:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

       or: -c --help [cmd1 cmd2 ...]

       or: -c --help-commands

       or: -c cmd --help



    error: invalid command 'egg_info'

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-HzKUun/ordereddict

「あれ、また同じエラーが?コレやれば治るって書いてあったのに!」 (人のせいにしてはいけません)
ということでまた別の方法を調べてみることに(※参考2)。

[ore@server ~]$ curl -O http://python-distribute.org/distribute_setup.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
[ore@server ~]$ sudo python distribute_setup.py
python: can't open file 'distribute_setup.py': [Errno 2] No such file or directory
[ore@server ~]$

「変だなぁ。なんでファイルが無いんだ?」と思って、直接ブラウザでアクセスしてみると...

http://python-distribute.org/distribute_setup.pyhttp://ww43.python-distribute.org/distribute_setup.py

「あれ、リダイレクトされてる... つーか、ドメインが売りに出されてるじゃん!そりゃDLできるファイル無いわ!!

ということで泣きそうになりながら更に調べることに。
そしたら、ありましたよ!解決方法が!

[ore@server ~]$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
--2015-09-16 11:58:39--  https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
Resolving bitbucket.org... 131.103.20.167, 131.103.20.168
Connecting to bitbucket.org|131.103.20.167|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11434 (11K) [text/plain]
Saving to: “ez_setup.py”

100%[==========================================================>] 11,434      --.-K/s   in 0s

2015-09-16 11:58:40 (333 MB/s) - “ez_setup.py” saved [11434/11434]

[ore@server ~]$ sudo python ez_setup.py
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-18.3.1.zip
Extracting in /tmp/tmprVQjOi
Now working in /tmp/tmprVQjOi/setuptools-18.3.1
Installing Setuptools
running install
running bdist_egg
running egg_info
(snip...)
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying setuptools.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying setuptools.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying setuptools.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying setuptools.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying setuptools.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying setuptools.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying setuptools.egg-info/zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
creating dist
creating 'dist/setuptools-18.3.1-py2.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing setuptools-18.3.1-py2.6.egg
Copying setuptools-18.3.1-py2.6.egg to /usr/lib/python2.6/site-packages
Adding setuptools 18.3.1 to easy-install.pth file
Installing easy_install script to /usr/bin
Installing easy_install-2.6 script to /usr/bin

Installed /usr/lib/python2.6/site-packages/setuptools-18.3.1-py2.6.egg
Processing dependencies for setuptools==18.3.1
Finished processing dependencies for setuptools==18.3.1

「お、もしかするとこれでイケる?」

[ore@server ~]$ sudo pip install --upgrade awscli
Collecting awscli from https://pypi.python.org/packages/py2.py3/a/awscli/awscli-1.8.4-py2.py3-none-any.whl#md5=f7a52bd35ff7ed1b8eede7cb82049f39
  Using cached awscli-1.8.4-py2.py3-none-any.whl
Requirement already up-to-date: colorama<=0.3.3,>=0.2.5 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already up-to-date: docutils>=0.10 in /usr/lib/python2.6/site-packages (from awscli)
Collecting argparse>=1.1 from https://pypi.python.org/packages/2.7/a/argparse/argparse-1.4.0-py2.py3-none-any.whl#md5=c37216a954c8669054e2b2c54853dd49 (from awscli)
  Using cached argparse-1.4.0-py2.py3-none-any.whl
Requirement already up-to-date: rsa<=3.1.4,>=3.1.2 in /usr/lib/python2.6/site-packages (from awscli)
Collecting botocore==1.2.2 (from awscli)
  Using cached botocore-1.2.2-py2.py3-none-any.whl
Requirement already up-to-date: pyasn1>=0.1.3 in /usr/lib/python2.6/site-packages (from rsa<=3.1.4,>=3.1.2->awscli)
Collecting ordereddict==1.1 (from botocore==1.2.2->awscli)
  Using cached ordereddict-1.1.tar.gz
    /tmp/pip-build-kYyZ1w/ordereddict/setup.py:12: DeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.

(snip...)

  Found existing installation: awscli 1.7.45
    Uninstalling awscli-1.7.45:
      Successfully uninstalled awscli-1.7.45

Successfully installed argparse-1.4.0 awscli-1.8.4 botocore-1.2.2 ordereddict-1.1 simplejson-3.3.0
[ore@server ~]$ aws --version
aws-cli/1.8.4 Python/2.6.6 Linux/2.6.32-504.1.3.el6.centos.plus.x86_64

「いけたっ...!」


簡潔にまとめると、これをDLしてsudo python ez_setup.pyを実行することで解消されました!!(※参考3)
Jameel Grandさん、ありがとうございました!

このハマりが誰かのお悩み解決になれば幸いです。


参考:
1. http://kaworu.jpn.org/python/pip#.E8.A7.A3.E6.B1.BA.E6.96.B9.E6.B3.95_2
2. http://blog.gogo-games.com/archives/28446278.html
3. http://stackoverflow.com/questions/31719816/pip-fails-to-install-anything-error-invalid-command-egg-info

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4