我的代码:
import pysftp
s = pysftp.Connection(host='test.rebex.net', username='demo', password='password')
data = s.listdir()
s.close()
for i in data:
print i
我在尝试使用 pysftp 连接到 SFTP 服务器时遇到错误。
这应该足够直截了当,但我收到以下错误:
Traceback (most recent call last):
File "/Users/gavinhinfey/Documents/Python Files/sftp_test.py", line 3, in <module>
s = pysftp.Connection(host='test.rebex.net', username='demo', password='password')
File "build/bdist.macosx-10.6-intel/egg/pysftp.py", line 55, in __init__
File "build/bdist.macosx-10.5-intel/egg/paramiko/transport.py", line 303, in __init__
paramiko.SSHException: Unable to connect to test.rebex.net: [Errno 60] Operation timed out
Exception AttributeError: "'Connection' object has no attribute '_tranport_live'" in <bound method Connection.__del__ of <pysftp.Connection object at 0x101a5a810>> ignored
我尝试过使用不同版本的 python(主要是 2.7),我安装了所有依赖项,并尝试了许多 sftp 连接。我正在使用 OS X 10.9.1。
原文由 Gavin Hinfey 发布,翻译遵循 CC BY-SA 4.0 许可协议
最初的错误似乎是与远程服务器的连接问题 (SSHException)。第二个 (AttributeError) 来自连接失败时发生的代码错误。它已在最新版本的pysftp中修复
https://pypi.python.org/pypi/pysftp
是你的朋友。