Run remote python code via ssh with uninstalled modules
<p>I wish to connect to a Linux machine by ssh (from my code) and run some code that is using python libraries that are not installed on the remote machine, what would be the best way to do so?</p>

<p>using a call like this:</p>

<pre><code>cat main.py | ssh user@server python -
</code></pre>

<p>will run main.py on the server, but wont help me with the dependencies, is there a way to somehow 'compile' the relevant libraries and have them sent over just for the running my code? </p>

<p>I wish to avoid installing the libraries on the remote machine if possible</p>

<p>Try <a href="https://virtualenv.pypa.io/en/stable/" rel="nofollow">virtualenv</a>:</p>

<pre><code>pip install virtualenv
</code></pre>

<p>then use</p>

<pre><code>virtualenv venv
</code></pre>

<p>to create a seperated python environment in current path(in folder <code>venv</code>).</p>

<p>Instead of installing multiple packages in default python path, virtualenv needs only one package installed.</p>

python linux ssh