简单的pysFTP昨晚正常工作,但现在无法正常工作

时间:2019-08-14 13:52:48

标签: python-3.x azure-databricks pysftp

昨晚,我正在编写我的第一个pySFTP笔记本,并且能够使它正常工作。我上床睡觉一直在工作,但现在没有了。我在连接命令时收到错误消息。...

import pysftp
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None    # disable host key checking.
#with pysftp.Connection('test.rebex.net', username='demo',password='password', cnopts=cnopts) as sftp:
# do stuff here
#  print('this works!')


s = pysftp.Connection(host='test.rebex.net', username='demo', password='password', cnopts=cnopts) 
data = s.listdir() 
s.close() 
for i in data: 
    print (i)

我收到的错误是...

Unknown exception: from_buffer() cannot return the address of the raw string within a bytes or unicode object
Traceback (most recent call last):
  File "/databricks/python/lib/python3.5/site-packages/paramiko/transport.py", line 2075, in run
    self.kex_engine.parse_next(ptype, m)
  File "/databricks/python/lib/python3.5/site-packages/paramiko/kex_curve25519.py", line 64, in parse_next
    return self._parse_kexecdh_reply(m)
  File "/databricks/python/lib/python3.5/site-packages/paramiko/kex_curve25519.py", line 129, in _parse_kexecdh_reply
    self.transport._activate_outbound()
  File "/databricks/python/lib/python3.5/site-packages/paramiko/transport.py", line 2553, in _activate_outbound
    self.local_cipher, key_out, IV_out, self._ENCRYPT
  File "/databricks/python/lib/python3.5/site-packages/paramiko/transport.py", line 1934, in _get_cipher
    return cipher.encryptor()
  File "/databricks/python/lib/python3.5/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 121, in encryptor
    self.algorithm, self.mode
  File "/databricks/python/lib/python3.5/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 298, in create_symmetric_encryption_ctx
    return _CipherContext(self, cipher, mode, _CipherContext._ENCRYPT)
  File "/databricks/python/lib/python3.5/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 67, in __init__
    iv_nonce = self._backend._ffi.from_buffer(mode.nonce)
TypeError: from_buffer() cannot return the address of the raw string within a bytes or unicode object

TypeError: from_buffer() cannot return the address of the raw string within a bytes or unicode object

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

pysftpparamiko列为one of its dependenciesParamiko issue #1037文档并将代码中引发的错误归因于cryptography的版本兼容性问题。

为避免这种情况,我的建议如下:

  1. 使用Databricks Conda Runtime改善Python依赖关系管理和可见性
  2. 升级密码版本(我在cryptography=2.6.1 conda env中包含了databricks-standard的条件下进行测试)