title: python paramiko error "AttributeError: 'NoneType' object has no attribute 'open_session'"
body: <p>I'm trying python paramiko module, got below error. How can I solve this? (I searched a lot, but no lucky)
   Any replies will be appreciated. (On Mac OS)</p>
  
  <p>python2.7 aaa.py</p>
  
  <pre><code>Traceback (most recent call last):
    File "aaa.py", line 24, in &lt;module&gt;
      ssh_command('172.16.129.130', 22, 'user', 'password', 'ls')
    File "aaa.py", line 14, in ssh_command
      stdin,stdout,stderr = client.exec_command(command)
    File "/Users/usera/anaconda2/lib/python2.7/site-            packages/paramiko/client.py", line 480, in exec_command
      chan = self._transport.open_session(timeout=timeout)
  AttributeError: 'NoneType' object has no attribute 'open_session'
  </code></pre>
  
  <p>Python version</p>
  
  <pre><code>Python 2.7.14 |Anaconda, Inc.| (default, Dec  7 2017, 11:07:58) 
  [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  </code></pre>
  
  <p>Python code</p>
  
  <pre><code>cat aaa.py
  #-*- coding:utf-8 -*-
  
  import paramiko
  
  #def ssh_command(ip, port, username, password, command='pwd; ls'):
  def ssh_command(ip, port, username, password, command):
  
      paramiko.util.log_to_file("filename.log")
  
      client = paramiko.SSHClient()
      client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
      client.connect = (ip, port, username, password)
      #stdin, stdout, stderr = client.exec_command(command)
      stdin,stdout,stderr = client.exec_command(command)
      #input = stdin.read()
      output = stdout.read()
      #output_error = stderr.read()
  
      print ouput.decode('utf-8')
  
      # Close the connect
      client.close()
  
  ssh_command('172.16.129.130', 22, 'user', 'password', 'ls')
  </code></pre>