简体   繁体   English

Python Paramiko,尝试连接时关闭属性错误“ Nonetype”

[英]Python Paramiko, Attribute Error 'Nonetype' on close when trying to connect

I'm trying to connect through Paramiko to an external SFTP and passing an encrypted config file for the credentials. 我正在尝试通过Paramiko连接到外部SFTP,并为凭据传递加密的配置文件。 When attempting to connect with the following, I get an error for the exception client.close that states AttributeError: 'Nonetype' object has not attribute 'close': 当尝试连接以下内容时,出现异常client.close的错误,该错误指出AttributeError:'Nonetype'对象没有属性'close':

client = None
try:
    client = paramiko.Transport(hostname, port)
    client.connect(username=username, password=password)
except Exception as e:
    client.close()
    return 'Cannot connect to SFTP server: ' + str(e.args[-1]), []
# Go
sftp = paramiko.SFTPClient.from_transport(client)

在异常中,您正在调用方法client.close() ,因为方法client.connect ,该方法将引发错误,请删除此方法或为每个可能的错误创建一个例外,以进行代码处理该特定错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python NoneType属性错误 - python NoneType attribute error 尝试使用 Python Paramiko 建立 SSH 连接时出现“getaddrinfo”错误 - "getaddrinfo" error when trying to establish an SSH connection using Python Paramiko Paramiko:尝试在远程服务器上执行 python 时抛出错误 - Paramiko : Throwing error when trying to execute python on remote server Python AttributeError:NoneType对象没有属性'close' - Python AttributeError: NoneType object has no attribute 'close' Python paramiko 错误“TypeError: 'NoneType' object is not iterable”仅适用于特定计算机 - Python paramiko error "TypeError: 'NoneType' object is not iterable" only for a particular computer Python-属性错误,“ NoneType”对象没有属性 - Python - Attribute error, 'NoneType' object has no attribute AttributeError: 'NoneType' 对象没有属性 'time' paramiko - AttributeError: 'NoneType' object has no attribute 'time' paramiko 在python GDAL / OSGEO / OGR / OSR上运行,尝试创建shapefile但出现错误:“ NoneType”对象没有属性“ CreateLayer” - Running on python GDAL/OSGEO/OGR/OSR, trying to create a shapefile but get error: 'NoneType' object has no attribute 'CreateLayer' 尝试从 SFTP 服务器传输文件时出现 Python Paramiko UTF-8 错误 - Python Paramiko UTF-8 error when trying to stream file from SFTP server Python AttributeError:'NoneType'对象在尝试保存裁剪图像时没有属性'save' - Python AttributeError: 'NoneType' object has no attribute 'save' when trying to save a cropped image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM