scheduler-cliのインストールエラー。Python3じゃないと使えない?

書くこと

AWSにInstance Schedulerというソリューションがあります。

AWS Instance Scheduler

この中で使われているscheduler-cliというコマンドをインストールしようと思ったのですが、エラーでできない。

AWSの公式ドキュメント通りにやってるのにできないのでトラブルシュートしました。

発生したエラー

公式ドキュメント通りにやると、以下のエラーが発生しました。

$ python --version
Python 2.7.18
sh-4.2$ 
sh-4.2$ cat /etc/system-release
Amazon Linux release 2 (Karoo)
$
$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
$
$ cat /etc/image-id
image_name="amzn2-ami-hvm"
image_version="2"
image_arch="x86_64"
image_file="amzn2-ami-hvm-2.0.20211001.1-x86_64.xfs.gpt"
image_stamp="81e7-33b1"
image_date="20211005133007"
recipe_name="amzn2 ami"
recipe_id="b2b2ae9a-dcb9-23a0-1c4c-b812-c490-85b1-d3f0f089"
$
$ whoami
ssm-user
$
$ cd /home/ssm-user/
$
$ pwd
/home/ssm-user
$
$ sudo wget https://s3.amazonaws.com/solutions-reference/aws-instance-scheduler/latest/scheduler-cli.zip
--2021-10-26 01:46:12--  https://s3.amazonaws.com/solutions-reference/aws-instance-scheduler/latest/scheduler-cli.zip
Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.216.137.46
Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.216.137.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5643 (5.5K) [application/zip]
Saving to: ‘scheduler-cli.zip’
100%[=========================================================================================================================================================================================================================================>] 5,643       --.-K/s   in 0s
2021-10-26 01:46:13 (106 MB/s) - ‘scheduler-cli.zip’ saved [5643/5643]
$
$ sudo unzip scheduler-cli.zip
Archive:  scheduler-cli.zip
  inflating: scheduler_cli/__init__.py
  inflating: scheduler_cli/__main__.py
  inflating: scheduler_cli/scheduler_cli.py
  inflating: setup.py
  inflating: instance-scheduler-cli-runner.py
$
$ sudo python setup.py install
/usr/lib/python2.7/site-packages/setuptools/dist.py:474: UserWarning: Normalizing 'v2.0.0' to '2.0.0'
  normalized_version,
running install
running bdist_egg
running egg_info
creating scheduler_cli.egg-info
writing requirements to scheduler_cli.egg-info/requires.txt
writing scheduler_cli.egg-info/PKG-INFO
writing top-level names to scheduler_cli.egg-info/top_level.txt
writing dependency_links to scheduler_cli.egg-info/dependency_links.txt
writing entry points to scheduler_cli.egg-info/entry_points.txt
writing manifest file 'scheduler_cli.egg-info/SOURCES.txt'
reading manifest file 'scheduler_cli.egg-info/SOURCES.txt'
writing manifest file 'scheduler_cli.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
※※※(省略)※※※
Installed /usr/lib/python2.7/site-packages/s3transfer-0.5.0-py2.7.egg
Searching for botocore<1.23.0,>=1.22.3
Reading https://pypi.org/simple/botocore/
Downloading https://files.pythonhosted.org/packages/c4/80/887bf75741359a3b067b7cf6cf1c426e503e9d1130c6fd0cb5b2c4b08123/botocore-1.22.3.tar.gz#sha256=53ca22aeac9b53fe5ec1f40b8ca9620ffe8b054458abfeb9ab74bbe9e0b0ecfa
Best match: botocore 1.22.3
Processing botocore-1.22.3.tar.gz
Writing /tmp/easy_install-tNl0oD/botocore-1.22.3/setup.cfg
Running botocore-1.22.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tNl0oD/botocore-1.22.3/egg-dist-tmp-tJQeOh
warning: no files found matching 'botocore/vendored/requests/cacert.pem'
no previously-included directories found matching 'docs/build'
  File "build/bdist.linux-x86_64/egg/botocore/auth.py", line 121
    pairs.append(f'{quoted_key}={quoted_value}')
                                              ^
SyntaxError: invalid syntax
zip_safe flag not set; analyzing archive contents...
botocore.__init__: module references __file__
botocore.httpsession: module references __file__
botocore.vendored.six: module references __path__
creating /usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg
Extracting botocore-1.22.3-py2.7.egg to /usr/lib/python2.7/site-packages
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/auth.py", line 121
    pairs.append(f'{quoted_key}={quoted_value}')
                                              ^
SyntaxError: invalid syntax
Adding botocore 1.22.3 to easy-install.pth file
Installed /usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg
Searching for idna<3,>=2.5
Reading https://pypi.org/simple/idna/
Downloading https://files.pythonhosted.org/packages/a2/38/928ddce2273eaa564f6f50de919327bf3a00f091b5baba8dfa9460f3a8a8/idna-2.10-py2.py3-none-any.whl#sha256=b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0
Best match: idna 2.10
Processing idna-2.10-py2.py3-none-any.whl
Installing idna-2.10-py2.py3-none-any.whl to /usr/lib/python2.7/site-packages
Adding idna 2.10 to easy-install.pth file
Installed /usr/lib/python2.7/site-packages/idna-2.10-py2.7.egg
Searching for chardet<5,>=3.0.2
Reading https://pypi.org/simple/chardet/
Downloading https://files.pythonhosted.org/packages/19/c7/fa589626997dd07bd87d9269342ccb74b1720384a4d739a1872bd84fbe68/chardet-4.0.0-py2.py3-none-any.whl#sha256=f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5
Best match: chardet 4.0.0
Processing chardet-4.0.0-py2.py3-none-any.whl
Installing chardet-4.0.0-py2.py3-none-any.whl to /usr/lib/python2.7/site-packages
Adding chardet 4.0.0 to easy-install.pth file
Installing chardetect script to /usr/bin
Installed /usr/lib/python2.7/site-packages/chardet-4.0.0-py2.7.egg
Searching for certifi>=2017.4.17
Reading https://pypi.org/simple/certifi/
Downloading https://files.pythonhosted.org/packages/37/45/946c02767aabb873146011e665728b680884cd8fe70dde973c640e45b775/certifi-2021.10.8-py2.py3-none-any.whl#sha256=d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569
Best match: certifi 2021.10.8
Processing certifi-2021.10.8-py2.py3-none-any.whl
Installing certifi-2021.10.8-py2.py3-none-any.whl to /usr/lib/python2.7/site-packages
Adding certifi 2021.10.8 to easy-install.pth file
Installed /usr/lib/python2.7/site-packages/certifi-2021.10.8-py2.7.egg
Searching for jmespath==0.9.3
Best match: jmespath 0.9.3
Adding jmespath 0.9.3 to easy-install.pth file
Using /usr/lib/python2.7/site-packages
Searching for urllib3==1.25.9
Best match: urllib3 1.25.9
Adding urllib3 1.25.9 to easy-install.pth file
Using /usr/lib/python2.7/site-packages
Searching for python-dateutil==2.6.0
Best match: python-dateutil 2.6.0
Adding python-dateutil 2.6.0 to easy-install.pth file
Using /usr/lib/python2.7/site-packages
Searching for six==1.9.0
Best match: six 1.9.0
Adding six 1.9.0 to easy-install.pth file
Using /usr/lib/python2.7/site-packages
Finished processing dependencies for scheduler-cli==2.0.0
$
$ scheduler-cli --version
Traceback (most recent call last):
  File "/usr/bin/scheduler-cli", line 11, in 
    load_entry_point('scheduler-cli==2.0.0', 'console_scripts', 'scheduler-cli')()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "build/bdist.linux-x86_64/egg/scheduler_cli/scheduler_cli.py", line 18, in 
  File "/usr/lib/python2.7/site-packages/boto3-1.19.3-py2.7.egg/boto3/__init__.py", line 16, in 
    from boto3.session import Session
  File "/usr/lib/python2.7/site-packages/boto3-1.19.3-py2.7.egg/boto3/session.py", line 17, in 
    import botocore.session
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/session.py", line 30, in 
    import botocore.client
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/client.py", line 16, in 
    from botocore.args import ClientArgsCreator
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/args.py", line 26, in 
    from botocore.signers import RequestSigner
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/signers.py", line 19, in 
    import botocore.auth
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/auth.py", line 121
    pairs.append(f'{quoted_key}={quoted_value}')
                                              ^
SyntaxError: invalid syntax

Syntax Errorが発生しております。AWS公式ドキュメント通りにやってるのにエラーなんて信じられない。。

解決方法

scheduler-cliのインストール

「python setup.py install」を「python3 setup.py install」としてインストール成功しました。

$ sudo python3 setup.py install
/usr/lib/python3.7/site-packages/setuptools/dist.py:458: UserWarning: Normalizing 'v2.0.0' to '2.0.0'
  warnings.warn(tmpl.format(**locals()))
running install
running bdist_egg
running egg_info
writing scheduler_cli.egg-info/PKG-INFO
writing dependency_links to scheduler_cli.egg-info/dependency_links.txt
writing entry points to scheduler_cli.egg-info/entry_points.txt
writing requirements to scheduler_cli.egg-info/requires.txt
writing top-level names to scheduler_cli.egg-info/top_level.txt
reading manifest file 'scheduler_cli.egg-info/SOURCES.txt'
writing manifest file 'scheduler_cli.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/scheduler_cli
copying build/lib/scheduler_cli/__init__.py -> build/bdist.linux-x86_64/egg/scheduler_cli
copying build/lib/scheduler_cli/__main__.py -> build/bdist.linux-x86_64/egg/scheduler_cli
copying build/lib/scheduler_cli/scheduler_cli.py -> build/bdist.linux-x86_64/egg/scheduler_cli
byte-compiling build/bdist.linux-x86_64/egg/scheduler_cli/__init__.py to __init__.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scheduler_cli/__main__.py to __main__.cpython-37.pyc
byte-compiling build/bdist.linux-x86_64/egg/scheduler_cli/scheduler_cli.py to scheduler_cli.cpython-37.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying scheduler_cli.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scheduler_cli.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scheduler_cli.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scheduler_cli.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scheduler_cli.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying scheduler_cli.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/scheduler_cli-2.0.0-py3.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing scheduler_cli-2.0.0-py3.7.egg
Copying scheduler_cli-2.0.0-py3.7.egg to /usr/local/lib/python3.7/site-packages
Adding scheduler-cli 2.0.0 to easy-install.pth file
Installing scheduler-cli script to /usr/local/bin
Installed /usr/local/lib/python3.7/site-packages/scheduler_cli-2.0.0-py3.7.egg
Processing dependencies for scheduler-cli==2.0.0
Searching for boto3>=1.4.7
Reading https://pypi.org/simple/boto3/
Downloading https://files.pythonhosted.org/packages/f0/e0/b3c3dbfbd288ef52f9352b0c2ffe75d6618fd7f31abdbb07466aa0877c12/boto3-1.19.3-py3-none-any.whl#sha256=2dfc8cf34d6dfbdfca4c88e8fddf9fe95cde489fb83144fe35f989ec6790e325
Best match: boto3 1.19.3
Processing boto3-1.19.3-py3-none-any.whl
Installing boto3-1.19.3-py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding boto3 1.19.3 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/boto3-1.19.3-py3.7.egg
Searching for jmespath>=0.9.3
Reading https://pypi.org/simple/jmespath/
Downloading https://files.pythonhosted.org/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl#sha256=cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f
Best match: jmespath 0.10.0
Processing jmespath-0.10.0-py2.py3-none-any.whl
Installing jmespath-0.10.0-py2.py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding jmespath 0.10.0 to easy-install.pth file
Installing jp.py script to /usr/local/bin
Installed /usr/local/lib/python3.7/site-packages/jmespath-0.10.0-py3.7.egg
Searching for requests>=2.18.4
Reading https://pypi.org/simple/requests/
Downloading https://files.pythonhosted.org/packages/92/96/144f70b972a9c0eabbd4391ef93ccd49d0f2747f4f6a2a2738e99e5adc65/requests-2.26.0-py2.py3-none-any.whl#sha256=6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24
Best match: requests 2.26.0
Processing requests-2.26.0-py2.py3-none-any.whl
Installing requests-2.26.0-py2.py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding requests 2.26.0 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/requests-2.26.0-py3.7.egg
Searching for argparse
Reading https://pypi.org/simple/argparse/
Downloading https://files.pythonhosted.org/packages/f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl#sha256=c31647edb69fd3d465a847ea3157d37bed1f95f19760b11a47aa91c04b666314
Best match: argparse 1.4.0
Processing argparse-1.4.0-py2.py3-none-any.whl
Installing argparse-1.4.0-py2.py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding argparse 1.4.0 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/argparse-1.4.0-py3.7.egg
Searching for s3transfer<0.6.0,>=0.5.0
Reading https://pypi.org/simple/s3transfer/
Downloading https://files.pythonhosted.org/packages/ab/84/fc3717a7b7f0f6bb08af593127171f08e3e0087c197922da09c01bfe7c3a/s3transfer-0.5.0-py3-none-any.whl#sha256=9c1dc369814391a6bda20ebbf4b70a0f34630592c9aa520856bf384916af2803
Best match: s3transfer 0.5.0
Processing s3transfer-0.5.0-py3-none-any.whl
Installing s3transfer-0.5.0-py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding s3transfer 0.5.0 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/s3transfer-0.5.0-py3.7.egg
Searching for botocore<1.23.0,>=1.22.3
Reading https://pypi.org/simple/botocore/
Downloading https://files.pythonhosted.org/packages/83/2f/21de0741da7565702eee6b42813892d5ceb53ecf60383c22488c5bbf0ff1/botocore-1.22.3-py3-none-any.whl#sha256=aacdb9b8e09e356515966251d1e08d9929575a76af504992bfb941553dee59c2
Best match: botocore 1.22.3
Processing botocore-1.22.3-py3-none-any.whl
Installing botocore-1.22.3-py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding botocore 1.22.3 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/botocore-1.22.3-py3.7.egg
Searching for urllib3<1.27,>=1.21.1
Reading https://pypi.org/simple/urllib3/
Downloading https://files.pythonhosted.org/packages/af/f4/524415c0744552cce7d8bf3669af78e8a069514405ea4fcbd0cc44733744/urllib3-1.26.7-py2.py3-none-any.whl#sha256=c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844
Best match: urllib3 1.26.7
Processing urllib3-1.26.7-py2.py3-none-any.whl
Installing urllib3-1.26.7-py2.py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding urllib3 1.26.7 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/urllib3-1.26.7-py3.7.egg
Searching for idna<4,>=2.5
Reading https://pypi.org/simple/idna/
Downloading https://files.pythonhosted.org/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl#sha256=84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff
Best match: idna 3.3
Processing idna-3.3-py3-none-any.whl
Installing idna-3.3-py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding idna 3.3 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/idna-3.3-py3.7.egg
Searching for charset-normalizer~=2.0.0
Reading https://pypi.org/simple/charset-normalizer/
Downloading https://files.pythonhosted.org/packages/de/c8/820b1546c68efcbbe3c1b10dd925fbd84a0dda7438bc18db0ef1fa567733/charset_normalizer-2.0.7-py3-none-any.whl#sha256=f7af805c321bfa1ce6714c51f254e0d5bb5e5834039bc17db7ebe3a4cec9492b
Best match: charset-normalizer 2.0.7
Processing charset_normalizer-2.0.7-py3-none-any.whl
Installing charset_normalizer-2.0.7-py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding charset-normalizer 2.0.7 to easy-install.pth file
Installing normalizer script to /usr/local/bin
Installed /usr/local/lib/python3.7/site-packages/charset_normalizer-2.0.7-py3.7.egg
Searching for certifi>=2017.4.17
Reading https://pypi.org/simple/certifi/
Downloading https://files.pythonhosted.org/packages/37/45/946c02767aabb873146011e665728b680884cd8fe70dde973c640e45b775/certifi-2021.10.8-py2.py3-none-any.whl#sha256=d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569
Best match: certifi 2021.10.8
Processing certifi-2021.10.8-py2.py3-none-any.whl
Installing certifi-2021.10.8-py2.py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding certifi 2021.10.8 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/certifi-2021.10.8-py3.7.egg
Searching for python-dateutil<3.0.0,>=2.1
Reading https://pypi.org/simple/python-dateutil/
Downloading https://files.pythonhosted.org/packages/36/7a/87837f39d0296e723bb9b62bbb257d0355c7f6128853c78955f57342a56d/python_dateutil-2.8.2-py2.py3-none-any.whl#sha256=961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
Best match: python-dateutil 2.8.2
Processing python_dateutil-2.8.2-py2.py3-none-any.whl
Installing python_dateutil-2.8.2-py2.py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding python-dateutil 2.8.2 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/python_dateutil-2.8.2-py3.7.egg
Searching for six>=1.5
Reading https://pypi.org/simple/six/
Downloading https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl#sha256=8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
Best match: six 1.16.0
Processing six-1.16.0-py2.py3-none-any.whl
Installing six-1.16.0-py2.py3-none-any.whl to /usr/local/lib/python3.7/site-packages
Adding six 1.16.0 to easy-install.pth file
Installed /usr/local/lib/python3.7/site-packages/six-1.16.0-py3.7.egg
Finished processing dependencies for scheduler-cli==2.0.0
$

しかしこれだけだと、scheduler-cliコマンドが使用できません。デフォルトで使用するPythonが2系になっているからだと思われます。

以下、エラーです。

$ scheduler-cli --version
Traceback (most recent call last):
  File "/usr/bin/scheduler-cli", line 11, in <module>
    load_entry_point('scheduler-cli==2.0.0', 'console_scripts', 'scheduler-cli')()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "build/bdist.linux-x86_64/egg/scheduler_cli/scheduler_cli.py", line 18, in <module>
  File "/usr/lib/python2.7/site-packages/boto3-1.19.3-py2.7.egg/boto3/__init__.py", line 16, in <module>
    from boto3.session import Session
  File "/usr/lib/python2.7/site-packages/boto3-1.19.3-py2.7.egg/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/session.py", line 30, in <module>
    import botocore.client
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/client.py", line 16, in <module>
    from botocore.args import ClientArgsCreator
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/args.py", line 26, in <module>
    from botocore.signers import RequestSigner
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/signers.py", line 19, in <module>
    import botocore.auth
  File "/usr/lib/python2.7/site-packages/botocore-1.22.3-py2.7.egg/botocore/auth.py", line 121
    pairs.append(f'{quoted_key}={quoted_value}')
                                              ^
SyntaxError: invalid syntax
$

デフォルトで使用するPythonを3系にする

Python3はインストール済みでした。

$ python3 --version
Python 3.7.10
$

デフォルトで使用するPythonを3系に変えます。ssm-userの「~/.bashrc」に書き込みます。

$ echo 'alias python=python3.7' >> ~/.bashrc
$
$ source ~/.bashrc
[ssm-user@ip-10-0-1-193 bin]$
[ssm-user@ip-10-0-1-193 bin]$ whoami
ssm-user
[ssm-user@ip-10-0-1-193 bin]$
[ssm-user@ip-10-0-1-193 bin]$ python --version
Python 3.7.10
[ssm-user@ip-10-0-1-193 bin]$

これでscheduler-cliコマンドが使えるようになるはず。

$ scheduler-cli --version
scheduler-cli v2.0.0
$

使えるようになりました。

ssm-user以外でも使用したい場合は、各ユーザーの「~/.bashrc」に書くことになるのかな。

参考サイト

AmazonLinux2でPython3環境構築

botocore/auth.py returns “SyntaxError: invalid syntax” #2526

この記事が気に入ったら
フォローしてね!

よかったらシェアしてね!

コメント

コメントする

CAPTCHA