:::: MENU ::::

CentOS6.5でPython2.6.6の環境にAWS CLIをインストールする

古いOSの標準Pythonだとインストール時にエラーになる。
別バージョンのPythonをインストールできない状況だった場合の対処法。

実行環境

$ cat /etc/redhat-release
CentOS release 6.5 (Final)
$ python -V
Python 2.6.6

pipのインストール

AWS CLI のインストールと設定 - Amazon Kinesis Streams

$ curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
$ sudo python get-pip.py

pip自体はこれで普通にインストールできる。

AWS CLIのインストール

そのまま入れてもエラーになる

$ sudo pip install awscli
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting awscli
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: 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/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: 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/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading awscli-1.11.177-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 1.1MB/s
Collecting rsa<=3.5.0,>=3.1.2 (from awscli)
Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)
100% |████████████████████████████████| 51kB 9.0MB/s
Requirement already satisfied: botocore==1.7.35 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.9 in /usr/lib/python2.6/site-packages (from awscli)
Collecting argparse>=1.1; python_version == "2.6" (from awscli)
Downloading argparse-1.4.0-py2.py3-none-any.whl
Requirement already satisfied: docutils>=0.10 in /usr/lib/python2.6/site-packages (from awscli)
Collecting colorama<=0.3.7,>=0.2.5 (from awscli)
Downloading colorama-0.3.7-py2.py3-none-any.whl
Collecting PyYAML<=3.12,>=3.10 (from awscli)
Downloading PyYAML-3.12.tar.gz (253kB)
100% |████████████████████████████████| 256kB 4.7MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-CBNEBD/PyYAML/setup.py", line 83, in <module>
from wheel.bdist_wheel import bdist_wheel
File "/usr/lib/python2.6/site-packages/wheel/bdist_wheel.py", line 407
ignore=lambda x, y: {'PKG-INFO', 'requires.txt', 'SOURCES.txt',
^
SyntaxError: invalid syntax

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

PyYAMLでこけているが実際にはwheelのバージョン問題でエラーになっている。

Wheel 0.30.0 dropped Python 2.6, 3.2, and 3.3 (SyntaxError: invalid syntax bdist_wheel.py", line 407) · Issue #2818 · aws/aws-cli

wheelの0.29.0にダウングレードしてからAWS CLIをインストールしなおせばよい。

$ sudo pip install wheel==0.29.0
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting wheel==0.29.0
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: 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/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: 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/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 5.9MB/s
Collecting argparse; python_version == "2.6" (from wheel==0.29.0)
Using cached argparse-1.4.0-py2.py3-none-any.whl
Installing collected packages: argparse, wheel
Found existing installation: wheel 0.30.0
Uninstalling wheel-0.30.0:
Successfully uninstalled wheel-0.30.0
Successfully installed argparse-1.4.0 wheel-0.29.0

$ sudo pip install awscli
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting awscli
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: 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/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: 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/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached awscli-1.11.177-py2.py3-none-any.whl
Collecting rsa<=3.5.0,>=3.1.2 (from awscli)
Using cached rsa-3.4.2-py2.py3-none-any.whl
Requirement already satisfied: botocore==1.7.35 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.9 in /usr/lib/python2.6/site-packages (from awscli)
Requirement already satisfied: argparse>=1.1; python_version == "2.6" in /usr/lib/python2.6/site-packages (from awscli)
Requirement already satisfied: docutils>=0.10 in /usr/lib/python2.6/site-packages (from awscli)
Collecting colorama<=0.3.7,>=0.2.5 (from awscli)
Using cached colorama-0.3.7-py2.py3-none-any.whl
Collecting PyYAML<=3.12,>=3.10 (from awscli)
Using cached PyYAML-3.12.tar.gz
Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli)
Downloading pyasn1-0.3.7-py2.py3-none-any.whl (63kB)
100% |████████████████████████████████| 71kB 6.1MB/s
Requirement already satisfied: simplejson==3.3.0; python_version == "2.6" in /usr/lib/python2.6/site-packages (from botocore==1.7.35->awscli)
Requirement already satisfied: ordereddict==1.1; python_version == "2.6" in /usr/lib/python2.6/site-packages (from botocore==1.7.35->awscli)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/lib/python2.6/site-packages (from botocore==1.7.35->awscli)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /usr/lib/python2.6/site-packages (from botocore==1.7.35->awscli)
Requirement already satisfied: futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" in /usr/lib/python2.6/site-packages (from s3transfer<0.2.0,>=0.1.9->awscli)
Requirement already satisfied: six>=1.5 in /usr/lib/python2.6/site-packages (from python-dateutil<3.0.0,>=2.1->botocore==1.7.35->awscli)
Building wheels for collected packages: PyYAML
Running setup.py bdist_wheel for PyYAML ... done
Stored in directory: /root/.cache/pip/wheels/2c/f7/79/13f3a12cd723892437c0cfbde1230ab4d82947ff7b3839a4fc
Successfully built PyYAML
Installing collected packages: pyasn1, rsa, colorama, PyYAML, awscli
Successfully installed PyYAML-3.12 awscli-1.11.177 colorama-0.3.7 pyasn1-0.3.7 rsa-3.4.2