Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Python 3 calls paramiko module to report an error AttributeError: what should module do?

Shulou Source: shulou.com Published: 2022-06-01 17:56:38 09月11日 Update

Python 3 call paramiko module error AttributeError: module how to do, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Python 3 calls paramiko module to report error AttributeError: module 'paramiko' has no attribute' SSHClient'

[root@MySQL01 script] # python paramiko.py

Exception occurs...

Traceback (most recent call last):

File "paramiko.py", line 2, in

Import paramiko

File "/ script/paramiko.py", line 8, in

Client = paramiko.SSHClient ()

AttributeError: module 'paramiko' has no attribute' SSHClient'

# script content

#! / usr/bin/env python

Import paramiko

Username = "root"

Password = "123456"

Hostname = "192.168.56.102"

Port = 22

Try:

Client = paramiko.SSHClient ()

Client.set_missing_host_key_policy (paramiko.AutoAddPolicy ())

Client.connect (hostname, port, username, password)

T = client.get_transport ()

Sftp=paramiko.SFTPClient.from_transport (t)

D = sftp.stat ("/ opt/archer-1.1.1.zip")

Print (d)

Stdin, stdout, stderr = client.exec_command ('ls-trlh')

Result = stdout.readlines ()

Print (result)

Except Exception:

Print ('Exception occurs...')

Raise

Reason for reporting an error:

The python file name is the same as the paramiko module name.

Solution:

Rename the script name.

[root@MySQL01 script] # mv paramiko.py para.py

# call normally

[root@MySQL01 script] # python para.py

-rw-r--r-- 100 1431181 30 Mar 11:40?

['total 104K\ nfolk,'-rw-r--r--. 1 root root 9.8K Dec 13 14:26 install.log.syslog\ n rw-r--r--.,'- rw-r--r--. 1 root root 50K Dec 13 14:29 install.log\ n rw-.,'- rw-. 1 root root 1.6K Dec 13 14:29 anaconda-ks.cfg, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Templates, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Public, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Downloads, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Documents, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Desktop, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Videos, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Pictures, 'drwxr-xr-x. 2 root root 4.0K Dec 13 14:37 Music\ n rw-r--r--.,'- rw-r--r--. 1 root root 0 Feb 14 23:19 20180405.txt\ n']

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Module content name script help what to do clear same reason for this file name article novice method more knowledge industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Xiaomi macOS Shulou Technology