Note that there are some explanatory texts on larger screens.

plurals
  1. PONew to writing fabric file to install packages
    primarykey
    data
    text
    <pre><code>from fabric.api import sudo, put, run def install(): run('source /home/user/.virtualenvs/demo/bin/activate') run('pip install requests') if __name__ == '__main__': install() # to run this, do fab fabfile </code></pre> <p>Q1. I want to install pip in that environment. But after the script ran, requests is not install in the virtualenv. Why?</p> <p>Q2. I am asked to provide host information (the following is also the log for Q1). If my goal is to run on local, is there a better way to handle this? </p> <pre><code>No hosts found. Please specify (single) host string for connection: localhost [localhost] run: source /home/user/.virtualenvs/demo/bin/activate [localhost] Passphrase for private key: [localhost] Login password: [localhost] run: pip install requests [localhost] out: Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.7/dist-packages [localhost] out: Requirement already satisfied (use --upgrade to upgrade): certifi&gt;=0.0.7 in /usr/local/lib/python2.7/dist-packages (from requests) [localhost] out: Requirement already satisfied (use --upgrade to upgrade): oauthlib&gt;=0.1.0,&lt;0.2.0 in /usr/local/lib/python2.7/dist-packages (from requests) [localhost] out: Requirement already satisfied (use --upgrade to upgrade): chardet&gt;=1.0.0 in /usr/lib/python2.7/dist-packages (from requests) [localhost] out: Requirement already satisfied (use --upgrade to upgrade): rsa in /usr/local/lib/python2.7/dist-packages (from oauthlib&gt;=0.1.0,&lt;0.2.0-&gt;requests) [localhost] out: Requirement already satisfied (use --upgrade to upgrade): pyasn1&gt;=0.0.13 in /usr/local/lib/python2.7/dist-packages (from rsa-&gt;oauthlib&gt;=0.1.0,&lt;0.2.0-&gt;requests) [localhost] out: Cleaning up... [localhost] out: </code></pre> <hr> <p><strong>Update</strong></p> <p>I can install the packages in a single <code>run</code> command. Is there a better way to do that?</p> <p>Thanks.</p> <hr> <p>Here is the update code:</p> <pre><code>from fabric.api import sudo, put, run from fabric.context_managers import prefix def install(): with prefix('source /home/user/.virtualenvs/demo/bin/activate'): run('pip install requests') if __name__ == '__main__': install() </code></pre> <p><a href="http://docs.fabfile.org/en/1.2.0/api/core/context_managers.html?highlight=prefix#fabric.context_managers.prefix" rel="nofollow">http://docs.fabfile.org/en/1.2.0/api/core/context_managers.html?highlight=prefix#fabric.context_managers.prefix</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload