【问题标题】:Simple pysFTP was working last night, but now does not简单的 pysFTP 昨晚可以工作,但现在不行
【发布时间】:2019-12-21 02:16:50
【问题描述】:

昨晚我正在编写我的第一个 pySFTP Notebook,我能够让它工作。我上床睡觉的时候它还在工作,但现在不行了。我收到连接命令错误....

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

感谢您的帮助!

【问题讨论】:

  • 此错误似乎间歇性/不一致地发生。我将脚本安排为作业,有时它可以工作,而有时它不能 - 无论文件是否可用。
  • 另外,我需要更具体地了解将哪个 pysftp libraru 加载到我的集群中。我指定了 pysftp==0.2.9。这似乎没有解决问题。

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


【解决方案1】:

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

我为避免这种情况的建议包括:

  1. 使用 Databricks Conda Runtime 改进 Python 依赖项管理和可见性
  2. 升级加密版本(我用cryptography=2.6.1测试过,包含在databricks-standard conda env中)

【讨论】:

  • 这很好用!谢谢,迈尔斯!非常感谢您的帮助。
猜你喜欢
  • 2017-05-16
  • 2014-11-15
  • 1970-01-01
  • 2023-01-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-19
相关资源
最近更新 更多