ElastAlertがいつの間にかelasticsearch 5系に対応していた為、
インストールを試したところ、python-setuptoolsのバージョンを上げなくてはならなかった為、忘備録として。
ほぼ作業ログになってしまいました。
ElastiAlertについては別途書きたい・・・
OS : Amazon Linux AMI release 2016.09
elasticsearch : 5.1.1
ElastiAlert : elastalert==0.1.8
ElastAlert Install
手順はこちらの通り
$ git clone https://github.com/Yelp/elastalert.git
$ cd elastalert
$ python setup.py install
$ pip install -r requirements.txt
これだけなのですが
SyntaxError: '<' operator not allowed in environment markers
おこられる
SyntaxErrorとなってしまっている
# python setup.py install
running install
running bdist_egg
running egg_info
creating elastalert.egg-info
writing requirements to elastalert.egg-info/requires.txt
writing elastalert.egg-info/PKG-INFO
~ 略 ~
ERROR:root:Error parsing
Traceback (most recent call last):
File "/tmp/easy_install-0oVA9a/mock-2.0.0/.eggs/pbr-1.10.0-py2.7.egg/pbr/core.py", line 111, in pbr
attrs = util.cfg_to_args(path, dist.script_args)
File "/tmp/easy_install-0oVA9a/mock-2.0.0/.eggs/pbr-1.10.0-py2.7.egg/pbr/util.py", line 248, in cfg_to_args
kwargs = setup_cfg_to_setup_kwargs(config, script_args)
File "/tmp/easy_install-0oVA9a/mock-2.0.0/.eggs/pbr-1.10.0-py2.7.egg/pbr/util.py", line 431, in setup_cfg_to_setup_kwargs
if pkg_resources.evaluate_marker('(%s)' % env_marker):
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1483, in evaluate_marker
return cls.interpret(parser.expr(text).totuple(1)[1])
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1517, in interpret
return op(nodelist)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1431, in atom
return cls.interpret(nodelist[2])
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1517, in interpret
return op(nodelist)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1452, in comparison
raise SyntaxError(msg)
SyntaxError: '<' operator not allowed in environment markers
error: Setup script exited with error in setup command: Error parsing /tmp/easy_install-0oVA9a/mock-2.0.0/setup.cfg: SyntaxError: '<' operator not allowed in environment markers
どうもpython-setuptoolsが古いらしい
python-setuptoolsのバージョンを調査
# rpm -qa |grep setuptools
python27-setuptools-12.2-1.32.amzn1.noarch
python26-setuptools-12.2-1.32.amzn1.noarch
ついでに
# which easy_install
/usr/bin/easy_install
# grep EASY-INSTALL-ENTRY-SCRIPT /usr/bin/easy_install
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==12.2','console_scripts','easy_install-2.7'
setuptools==12.2
ということがわかった。
python-setuptoolsのアップデート
yum
素直にyumであげられないかと見てみたが、現在のバージョン(12.2-1.32)が最新となっている。
# yum info python27-setuptools
Loaded plugins: priorities, update-motd, upgrade-helper
4 packages excluded due to repository priority protections
Installed Packages
Name : python27-setuptools
Arch : noarch
Version : 12.2
Release : 1.32.amzn1
Size : 1.9 M
Repo : installed
Summary : Easily build and distribute Python packages
URL : http://pypi.python.org/pypi/setuptools
License : Python or ZPLv2.0
Description : Setuptools is a collection of enhancements to the Python distutils that allow
: you to more easily build and distribute Python packages, especially ones that
: have dependencies on other packages.
:
: This package contains the runtime components of setuptools, necessary to
: execute the software that requires pkg_resources.py.
:
: This package is meant to be used with Python 2.7.
# yum clean all
Loaded plugins: priorities, update-motd, upgrade-helper
Cleaning repos: amzn-main amzn-updates elasticsearch-5.x kibana-5.x treasuredata
Cleaning up everything
# yum install python27-setuptools.noarch
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.3 kB 00:00
4 packages excluded due to repository priority protections
Package python27-setuptools-12.2-1.32.amzn1.noarch already installed and latest version
Nothing to do
# yum search python27-setuptools
Loaded plugins: priorities, update-motd, upgrade-helper
4 packages excluded due to repository priority protections
====================================== N/S matched: python27-setuptools =======================================
python27-setuptools.noarch : Easily build and distribute Python packages
Name and summary matches only, use "search all" for everything.
インストールスクリプト
こちらの手順を参考に、インストールする
python26-setuptools,python27-setuptoolsをyum removeしようとしたが、
依存関係でcloud-initまで削除されてしまう。
# yum remove python*-setuptools
Dependencies Resolved
===============================================================================================================
Package Arch Version Repository Size
===============================================================================================================
Removing:
python26-setuptools noarch 12.2-1.32.amzn1 @amzn-main 1.9 M
python27-setuptools noarch 12.2-1.32.amzn1 installed 1.9 M
Removing for dependencies:
aws-cfn-bootstrap noarch 1.4-13.8.amzn1 installed 2.4 M
aws-cli noarch 1.11.17-1.43.amzn1 @amzn-updates 3.4 M
cloud-init noarch 0.7.6-2.14.amzn1 @amzn-updates 1.2 M
python27-babel noarch 0.9.4-5.1.8.amzn1 installed 5.2 M
python27-boto noarch 2.42.0-1.1.amzn1 installed 9.4 M
python27-jinja2 noarch 2.7.2-2.15.amzn1 installed 3.0 M
python27-pip noarch 6.1.1-1.23.amzn1 installed 6.3 M
python27-rsa noarch 3.4.1-1.8.amzn1 installed 256 k
python27-virtualenv noarch 12.0.7-1.13.amzn1 installed 2.8 M
Transaction Summary
===============================================================================================================
Remove 2 Packages (+9 Dependent packages)
Installed size: 38 M
Is this ok [y/N]:
ということでremoveせずにインストールを行ってみる。
yumでインストールしているeasy_installは/usr/bin/easy_installに、
今回インストールするのは/usr/local/bin/easy_installに置かれている。
# wget https://bootstrap.pypa.io/ez_setup.py -O - | python
--2017-02-24 09:43:05-- https://bootstrap.pypa.io/ez_setup.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.72.175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.72.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12537 (12K) [text/x-python]
Saving to: ‘STDOUT’
- 100%[==========================================>] 12.24K --.-KB/s in 0s
2017-02-24 09:43:05 (96.7 MB/s) - written to stdout [12537/12537]
ez_setup.py is deprecated and when using it setuptools will be pinned to 33.1.1 since it's the last version that supports setuptools self upgrade/installation, check https://github.com/pypa/setuptools/issues/581 for more info; use pip to install setuptools
Downloading https://pypi.io/packages/source/s/setuptools/setuptools-33.1.1.zip
Extracting in /tmp/tmpzEk9Hn
Now working in /tmp/tmpzEk9Hn/setuptools-33.1.1
Installing Setuptools
~ 略 ~
Copying setuptools-33.1.1-py2.7.egg to /usr/local/lib/python2.7/site-packages
Adding setuptools 33.1.1 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin
Installed /usr/local/lib/python2.7/site-packages/setuptools-33.1.1-py2.7.egg
Processing dependencies for setuptools==33.1.1
Finished processing dependencies for setuptools==33.1.1
# wget https://bootstrap.pypa.io/get-pip.py -O - | python
--2017-02-24 09:45:10-- https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.72.175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.72.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1595408 (1.5M) [text/x-python]
Saving to: ‘STDOUT’
- 100%[==========================================>] 1.52M --.-KB/s in 0.04s
2017-02-24 09:45:10 (41.3 MB/s) - written to stdout [1595408/1595408]
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 3.5MB/s
Installing collected packages: wheel
easy_installのデフォルトパスは/usr/local/bin/easy_installに置き換わった。
setuptools==33.1.1に上がった。
# which easy_install
/usr/local/bin/easy_install
# grep EASY-INSTALL-ENTRY-SCRIPT /usr/local/bin/easy_install
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==33.1.1','console_scripts','easy_install'
再びsetup.py
sixのバージョン不足
# python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to elastalert.egg-info/requires.txt
writing elastalert.egg-info/PKG-INFO
~ 略 ~
Adding httplib2 0.10.3 to easy-install.pth file
Installed /usr/local/lib/python2.7/site-packages/httplib2-0.10.3-py2.7.egg
error: six 1.8.0 is installed but six>=1.9 is required by set(['mock'])
# pip freeze |grep six
six==1.8.0
# pip install six\>\=1.9
Collecting six>=1.9
Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Found existing installation: six 1.8.0
Uninstalling six-1.8.0:
Successfully uninstalled six-1.8.0
Successfully installed six-1.10.0
# pip freeze |grep six
six==1.10.0
requestsのバージョン不足
Installed /usr/local/lib/python2.7/site-packages/requests_oauthlib-0.8.0-py2.7.egg
error: requests 1.2.3 is installed but requests>=2.0.0 is required by set(['requests-oauthlib'])
# pip install requests\>\=2.0.0
Collecting requests>=2.0.0
Downloading requests-2.13.0-py2.py3-none-any.whl (584kB)
100% |████████████████████████████████| 593kB 1.9MB/s
Installing collected packages: requests
Found existing installation: requests 1.2.3
Uninstalling requests-1.2.3:
Successfully uninstalled requests-1.2.3
Successfully installed requests-2.13.0
OK
# python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to elastalert.egg-info/requires.txt
writing elastalert.egg-info/PKG-INFO
~ 略 ~
Using /usr/lib/python2.7/dist-packages
Finished processing dependencies for elastalert==0.1.8
とりあえずインストール完了。