如何使用paramiko进行动态/运行时模块导入?

时间:2017-12-12 16:26:25

标签: python sftp python-import paramiko

我遇到了与SFTP服务器连接的paramiko问题。 Paramiko在与动态模块导入连接时挂起。我设法调查的是问题是由于动态模块导入(通过sys.path.append

我的问题与this question/answer有很多共同之处,但在我的情景中,这些问题与黑客有关。根本不工作。这是我的previous question,因为我只是STFP服务器连接问题。但事实上它与进口相关的问题。

我的问题是如何使用paramiko动态/运行时模块导入?

  File "bin/sftp.py", line 13, in <module>
    import main
  File "/home/ufnal/Downloads/sftp_not_working/main.py", line 17, in <module>
    main()
  File "/home/ufnal/Downloads/sftp_not_working/main.py", line 13, in main
    with SftpClient(address, 22, root, username, None, keypath) as sftp:
  File "/home/ufnal/Downloads/sftp_not_working/src/sftp_client.py", line 44, in __init__
    self._connect()
  File "/home/ufnal/Downloads/sftp_not_working/src/sftp_client.py", line 84, in _connect
    pkey=self.pkey, username=self.username, password=self.password)
  File "/home/ufnal/.local/lib/python2.7/site-packages/paramiko/transport.py", line 1173, in connect
    self.start_client()
  File "/home/ufnal/.local/lib/python2.7/site-packages/paramiko/transport.py", line 541, in start_client
    event.wait(0.1)
  File "/usr/lib/python2.7/threading.py", line 614, in wait
    self.__cond.wait(timeout)
  File "/usr/lib/python2.7/threading.py", line 359, in wait
    _sleep(delay)

0 个答案:

没有答案