Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python paramiko.transport在使用ssh连接到远程服务器时抛出运行时值错误_Python_Ssh_Cryptography_Paramiko_Pyinstaller - Fatal编程技术网

Python paramiko.transport在使用ssh连接到远程服务器时抛出运行时值错误

Python paramiko.transport在使用ssh连接到远程服务器时抛出运行时值错误,python,ssh,cryptography,paramiko,pyinstaller,Python,Ssh,Cryptography,Paramiko,Pyinstaller,我是Python初学者,正在尝试为我的项目构建一个应用程序,使用“Python2.7.11”从远程服务器获取日志。我使用“Paramiko 2.0.0”和“cryptography 1.3.2”来完成这项任务。当直接从空闲状态执行时,脚本工作正常。然后,我使用最新的PyInstaller-3.2来创建此应用程序的可执行文件。但可执行文件在创建与服务器的ssh连接时抛出运行时错误 执行此exe文件时,尝试使用以下代码连接到服务器: client = paramiko.SSHClient()

我是Python初学者,正在尝试为我的项目构建一个应用程序,使用“Python2.7.11”从远程服务器获取日志。我使用“Paramiko 2.0.0”和“cryptography 1.3.2”来完成这项任务。当直接从空闲状态执行时,脚本工作正常。然后,我使用最新的PyInstaller-3.2来创建此应用程序的可执行文件。但可执行文件在创建与服务器的ssh连接时抛出运行时错误

执行此exe文件时,尝试使用以下代码连接到服务器:

    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(hostname='<ip address is hardcoded here>',port=22, username='root', password='<password is hardcoded here>')
请帮助我理解并调试这个问题,因为我是Python新手,不太熟悉深入调试Python代码。
另外,如果需要更多关于脚本的信息进行分析,请告诉我。

我也遇到了同样的问题,使用的是PyInstaller-2.1,其他版本与您相同

将paramiko降级到1.17版,并使用PyInstaller重建exe为我解决了这个问题

pip uninstall paramiko
pip install paramiko==1.17
试试这个:

def patch_crypto():

  from cryptography.hazmat import backends

  try:
      from cryptography.hazmat.backends.commoncrypto.backend import backend as be_cc
  except ImportError:
      be_cc = None

  try:
      from cryptography.hazmat.backends.openssl.backend import backend as be_ossl
  except ImportError:
      be_ossl = None

  backends._available_backends_list = [
      be for be in (be_cc, be_ossl) if be is not None
  ]
然后


你能发布命令
pip freeze | grep pycrypto
的输出吗?@LFJ,我已经删除了之前的评论,并用正确的格式重新发布了它们。起初我没有安装pycrypto,在看到您的评论后,我安装了它。现在我已经安装了pycrypto 2.6.1,但问题仍然存在。您可以将这两行折叠成
pip安装-I paramiko==1.17
2。它还可以将密码学降级到1.2.3。这让我的py2app与paramiko的sshclient-cheers一起工作
def patch_crypto():

  from cryptography.hazmat import backends

  try:
      from cryptography.hazmat.backends.commoncrypto.backend import backend as be_cc
  except ImportError:
      be_cc = None

  try:
      from cryptography.hazmat.backends.openssl.backend import backend as be_ossl
  except ImportError:
      be_ossl = None

  backends._available_backends_list = [
      be for be in (be_cc, be_ossl) if be is not None
  ]
patch_crypto()