paramiko'module'没有属性'new'

时间:2017-05-26 14:59:49

标签: python ftp paramiko

我已经将这段代码用于FTP图像超过一年,没有任何改变,然后我突然在尝试FTP时遇到错误。我试过重启/等等。代码是(我已用'...'替换了地址):

with pysftp.Connection('...', username='...', password='...') as sftp:
    sftp.cd('...')
    sftp.put(figure1)

我使用paramiko v1.16和v2.1.2得到以下错误(尝试更新版本,但这没有解决它):

    ERROR:paramiko.transport:Unknown exception: 'module' object has no attribute 'new'

    ERROR:paramiko.transport:Traceback (most recent call last):

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\User\lib\site-packages\paramiko\transport.py", line 1744, in run

    ERROR:paramiko.transport:    self.kex_engine.parse_next(ptype, m)

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\User\lib\site-packages\paramiko\kex_group1.py", line 75, in parse_next

    ERROR:paramiko.transport:    return self._parse_kexdh_reply(m)

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\User\lib\site-packages\paramiko\kex_group1.py", line 111, in _parse_kexdh_reply

    ERROR:paramiko.transport:    self.transport._verify_key(host_key, sig)

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\User\lib\site-packages\paramiko\transport.py", line 1604, in _verify_key

    ERROR:paramiko.transport:    if not key.verify_ssh_sig(self.H, Message(sig)):

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\User\lib\site-packages\paramiko\rsakey.py", line 112, in verify_ssh_sig

    ERROR:paramiko.transport:    rsa = RSA.construct((long(self.n), long(self.e)))

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.2.2785.win-x86_64\lib\site-packages\Crypto\PublicKey\RSA.py", line 540, in construct

    ERROR:paramiko.transport:    return _RSAobj(self, key)

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.2.2785.win-x86_64\lib\site-packages\Crypto\PublicKey\RSA.py", line 117, in __init__

    ERROR:paramiko.transport:    randfunc = Random.new().read

    ERROR:paramiko.transport:  File "C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.2.2785.win-x86_64\lib\site-packages\Crypto\Random\__init__.py", line 33, in new

    ERROR:paramiko.transport:    return _UserFriendlyRNG.new(*args, **kwargs)

    ERROR:paramiko.transport:AttributeError: 'module' object has no attribute 'new'

    AttributeError                            Traceback (most recent call last)
    C:\Ceilometer_Code\launch_plot_CL31_YFB.py in <module>()
        261     print 'Launching sftp '
    --> 262     with pysftp.Connection('...', username='...', password='...') as sftp:
        263         sftp.cd('...')
        264         sftp.put(figure1)

    C:\Ceilometer_Code\pysftp.pyc in __init__(self, host, username, private_key, password, port, private_key_pass, ciphers, log)
        160         if password is not None:
        161             # Using Password.
    --> 162             self._transport.connect(username=username, password=password)
        163         else:
        164             # Use Private Key.

    C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\User\lib\site-packages\paramiko\transport.pyc in connect(self, hostkey, username, password, pkey, gss_host, gss_auth, gss_kex, gss_deleg_creds)
       1070             self._preferred_keys = [hostkey.get_name()]
       1071 
    -> 1072         self.start_client()
       1073 
       1074         # check host key if we were given one

    C:\Users\Default.Default-PC\AppData\Local\Enthought\Canopy\User\lib\site-packages\paramiko\transport.pyc in start_client(self, event)
        490                 e = self.get_exception()
        491                 if e is not None:
    --> 492                     raise e
        493                 raise SSHException('Negotiation failed.')
        494             if event.is_set():

    AttributeError: 'module' object has no attribute 'new' 

有谁知道如何解决这个问题?我已经确认我的SFTP un / pw是正确的,互联网有效等等。

1 个答案:

答案 0 :(得分:0)

需要加密更新;错误现在消失了,FTP正常。