title: Set up virtualenv with Paramiko SSH
body: <p>I have some limited experience with Python and Django in Windows, and now I am trying to understand how to deploy my code to an Ubuntu 16.04 LTS VPS. Having read various tutorials and a lot of answers on SE, I managed to proceed pretty far (well, for me), but now I am stuck.</p>
  
  <p>Manually (via Putty) I can do the following:</p>
  
  <pre><code># check that Python 3.5 is installed
  python3 --version  
  # install pip
  sudo -kS apt-get -y install python3-pip  
  # upgrade pip to newest version
  pip3 install --upgrade pip
  # check result
  pip3 --version  
  # install venv
  sudo -kS pip3 install virtualenv virtualenvwrapper 
  # create venv
  virtualenv ~/Env/firstsite  
  # make sure venv is created 
  ls -l ~/Env/firstsite/bin/python  # /home/droplet/Env/firstsite/bin/python3.5 -&gt; python3
  # switch on venv
  source ~/Env/firstsite/bin/activate  # (firstsite) droplet@hostname:~$
  # check that python3 is taken from venv
  which python3  # /home/droplet/Env/firstsite/bin/python3
  </code></pre>
  
  <p>So the virtual environment is properly created and switched on. I could proceed installing Django.</p>
  
  <p>However when I am trying to do exactly the same in the automated regime, using Paramiko (I execute commands using <code>paramiko.SSHClient().exec_command(cmd, input_string, get_pty=False</code>), everything goes exactly the same way, until the last command:</p>
  
  <pre><code>exec_command('which python3')
  </code></pre>
  
  <p>returns <code>/usr/bin/python3</code>. So I assume <code>source activate</code> doesn't work via Paramiko's SSH. </p>
  
  <ol>
  <li>Why? </li>
  <li>How can I cope with it?</li>
  <li>Can I check that the venv is enabled in some more direct (and reliable) way? </li>
  </ol>