运用paramiko远程执行命令报错:TypeError: from_buffer() cannot return the address of the raw string withi....

问题描述:

运用paramiko远程执行命令报错:

from cryptography.hazmat.backends import default_backend
No handlers could be found for logger "paramiko.transport"
Traceback (most recent call last):
  File "test.py", line 17, in <module>
    ssh()
  File "test.py", line 8, in ssh
    ssh.connect('172.17.0.3',22,'root','111')
  File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 406, in connect
    t.start_client(timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 660, in start_client
    raise e
TypeError: from_buffer() cannot return the address of the raw string within a str or unicode or bytearray object

原因分析:

paramiko和cryptography以及cffi组件模块版本不匹配。

解决方法:

先保证同时更新这三个组件模块:

pip install cffi -i https://pypi.douban.com/simple --trust -host=pypi.douban.com
pip install --upgrade cryptography -i https://pypi.douban.com/simple --trust -host=pypi.douban.com
pip install --upgrade paramiko -i https://pypi.douban.com/simple --trust -host=pypi.douban.com

如果还是报错,可能cffi在python路径中安装了cffi的多个副本。而默认用的是老的版本的cffi副本,可以执行如下操作解决:

pip uninstall cffi

apt-get purge --auto-remove python-cffi

pip install cffi -i https://pypi.douban.com/simple --trust -host=pypi.douban.com

至此,应该是可以成功了。 

 

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值