리눅스

stormssh 설치 후 collections 모듈 에러

변군이글루 2022. 11. 16. 09:53
반응형

stormssh 설치 후 collections 모듈 에러

테스트 환경

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy
$ python --version
Python 3.10.6

stormssh 버전 정보 확인

storm --version
$ storm --version
Traceback (most recent call last):
  File "/usr/local/bin/storm", line 5, in <module>
    from storm.__main__ import main
  File "/usr/local/lib/python3.10/dist-packages/storm/__main__.py", line 25, in <module>
    @command('version')
  File "/usr/local/lib/python3.10/dist-packages/storm/kommandr.py", line 98, in command
    if len(args) == 1 and isinstance(args[0], collections.Callable):
AttributeError: module 'collections' has no attribute 'Callable'

python 3.10부터는 collections.abc.Callable로 이동하였음

파이썬 버전 모듈(import) 속성 비고
python 3.9 이전 collections collections.Callable  
python 3.10 이후 collections.abc collections.abc.Callable  

storm 파일 편집

kommandr.py 편집

  • import collections > import collections.abc
  • collections.Callable > collections.abc.Callable
$ diff -Nur storm-python/kommandr.py /usr/local/lib/python3.10/dist-packages/storm/kommandr.py
--- storm-python/kommandr.py    2022-11-16 09:32:48.752776659 +0900
+++ /usr/local/lib/python3.10/dist-packages/storm/kommandr.py   2022-11-16 09:34:30.289253176 +0900
@@ -13,7 +13,7 @@
     from itertools import izip_longest
 except ImportError:
     from itertools import zip_longest as izip_longest
-import collections
+import collections.abc
 
 import six
 
@@ -95,7 +95,7 @@
 
     def command(self, *args, **kwargs):
         """Convenient decorator simply creates corresponding command"""
-        if len(args) == 1 and isinstance(args[0], collections.Callable):
+        if len(args) == 1 and isinstance(args[0], collections.abc.Callable):
             return self._generate_command(args[0])
         else:
             def _command(func):

stormssh(storm) 버전 정보 확인

storm --version
$ storm --version 
0.7.0

storm add

storm add web01 ec2-user@10.51.3.81:22 --id_file=~/aws/mykey.pem
$ storm add web01 ec2-user@10.51.3.81:22 --id_file=~/aws/mykey.pem
success  web01 added to your ssh config. you can connect it by typing "ssh web01".

storm list

storm list
$ storm list
error    module 'collections' has no attribute 'Sequence'

__main__.py 편집

  • collections.Sequence > collections.abc.Sequence
$ diff -Nur storm-python/__main__.py /usr/local/lib/python3.10/dist-packages/storm/__main__.py 
--- storm-python/__main__.py    2022-11-16 09:32:10.444597397 +0900
+++ /usr/local/lib/python3.10/dist-packages/storm/__main__.py   2022-11-16 09:58:19.483998247 +0900
@@ -224,7 +224,7 @@
                                 result += " {0}".format(custom_options)
                             extra = True
 
-                            if isinstance(value, collections.Sequence):
+                            if isinstance(value, collections.abc.Sequence):
                                 if isinstance(value, builtins.list):
                                     value = ",".join(value)
storm list
$ storm list
 Listing entries:

    web01 -> ec2-user@10.51.3.81:22 
        [custom options] identityfile="~/aws/mykey.pem"

 

참고URL

- ec2 인스턴스(Amazon Linux 2)에 stormssh 설치 및 설정하기 : https://scbyun.com/1125

- AttributeError: module collections has no attribute Callable : https://bobbyhadz.com/blog/python-attributeerror-module-collections-has-no-attribute-callable

 

반응형