PSSH – 异步并行的ssh库,官方镜像版本最新为2.3.1,不支持python3.2以上的版本。

For me, who is using python3.7 had following trouble

1
2
3
4
5
6
7
8
9
10
11
[root@cyhl-UC-prd1 pssh-2.3.1]# pssh --version
Traceback (most recent call last):
File "/usr/local/bin/pssh", line 4, in <module>
__import__('pkg_resources').run_script('pssh==2.3.1', 'pssh')
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 672, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1479, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python3.7/site-packages/pssh-2.3.1-py3.7.egg/EGG-INFO/scripts/pssh", line 26, in <module>
File "/usr/local/lib/python3.7/site-packages/pssh-2.3.1-py3.7.egg/psshlib/cli.py", line 9, in <module>
ModuleNotFoundError: No module named 'version'

Due to the version difference in Python3, I guess we don’t have this library avail.

Quick Fix:
Open this file error causing cli.py file from above code, and update to following changes

change 1
Find below code

1
import version

Change to below

1
2
3
4
5
try:
from version import VERSION
except:
print('[WARN] Could not import version package in', __file__)
VERSION = '2.3'

change 2
Find below code

1
2
parser = optparse.OptionParser(conflict_handler='resolve',
version=version.VERSION)

Change to below

1
2
parser = optparse.OptionParser(conflict_handler='resolve',
version=VERSION)

Hope you had it working now!

parallel-ssh 是为小规模自动化而设计的异步并行的 SSH 库,包括 pssh、pscp、prsync、pslurp 和 pnuke工具,其源代码使用 Python语言编写开发的。该项目最初位于Google Code上,是由Brent N.Chun编写和维护的,但是由于工作繁忙,Brent于2009年10月将维护工作移交给了Andrew McNabb管理。到了 2012年的时候,由于Google Code的已关闭,该项目一度被废弃,现在也只能在 Google Code 的归档中找到当时的版本了。

但是需要注意的是,之前的版本是不支持 Python3 的,但是 Github 上面有人 Fork 了一份,自己进行了改造使其支持 Python3 以上的版本了。与此同时,还有一个组织专门针对 parallel-ssh 进行了开发和维护,今天看了下很久都没有更新了。有需要的,自己可以自行查阅。

lilydjwg/pssh - supported on Python 3.5 and later

https://github.com/lilydjwg/pssh/archive/refs/tags/v2.3.4.tar.gz