擅长:python、mysql、java
<p>您可以使用以下命令获取所有依赖项(当然需要Internet连接)</p>
<pre><code>pip download -r requirements.txt
</code></pre>
<p>然后,可以使用以下命令脱机安装这些依赖项</p>
<blockquote>
<pre><code>pip install -r requirements.txt --no-index --find-links file:///tmp/packages
</code></pre>
<p><code>--no-index</code> : Ignore package index (only looking at <code>--find-links</code>
URLs instead). </p>
<p><code>-f, --find-links <URL></code> : If a URL or path to an html file, then
parse for links to archives. If a local path or <code>file://</code> URL that's a directory, then look for
archives in the directory listing.</p>
</blockquote>
<p>这个答案取自<a href="https://stackoverflow.com/questions/7225900/how-to-pip-install-packages-according-to-requirements-txt-from-a-local-directory">this post</a></p>