{"id":775,"date":"2019-05-30T15:50:43","date_gmt":"2019-05-30T07:50:43","guid":{"rendered":"https:\/\/wyxxt.org.cn\/?p=775"},"modified":"2023-12-04T16:58:36","modified_gmt":"2023-12-04T08:58:36","slug":"pip%e5%8c%85%e7%ae%a1%e7%90%86%e5%b7%a5%e5%85%b7","status":"publish","type":"post","link":"https:\/\/wyxxt.org.cn\/?p=775","title":{"rendered":"pip\u5305\u7ba1\u7406\u5de5\u5177"},"content":{"rendered":"<h1>1\u3001\u4f7f\u7528install\u547d\u4ee4\u5b89\u88c5\u5305<\/h1>\n<h2>1.1\u3001\u5b89\u88c5PyPI\u5305<\/h2>\n<pre><code class=\"language-shell line-numbers\">pip install SomePackage            # \u5b89\u88c5\u6700\u65b0\u7248\u672c\npip install SomePackage==1.0.4     # \u5b89\u88c5\u6307\u5b9a\u7248\u672c\npip install 'SomePackage&gt;=1.0.4'     # \u6307\u5b9a\u5b89\u88c5\u7684\u6700\u5c0f\u7248\u672c\n<\/code><\/pre>\n<h3>\u4f7f\u7528requirement.txt\u9700\u6c42\u6587\u4ef6<\/h3>\n<pre><code class=\"language-shell line-numbers\">pip install -r requirements.txt\n<\/code><\/pre>\n<h3>\u751f\u6210requirements.txt\u9700\u6c42\u6587\u4ef6<\/h3>\n<pre><code class=\"language-shell line-numbers\">pip freeze &gt; requirements.txt\n<\/code><\/pre>\n<h2>1.2\u3001\u5b89\u88c5wheel\u5305<\/h2>\n<p><em>wheel\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a zip \u5305\u683c\u5f0f\uff0c\u7528\u4e8e python \u6a21\u5757\u7684\u5b89\u88c5\uff0c\u5b83\u7684\u51fa\u73b0\u662f\u4e3a\u4e86\u66ff\u4ee3 \u8001\u7248\u672c\u7684Eggs\u3002pip\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5b89\u88c5wheel\u5305\u3002\u5982\u679c\u53d1\u5e03\u6a21\u5757\uff0c\u63a8\u8350\u4f7f\u7528 wheel \u683c\u5f0f\u3002<\/em><\/p>\n<pre><code class=\"language-shell line-numbers\">pip install SomePackage-1.0-py2.py3-none-any.whl\n<\/code><\/pre>\n<h2>1.3\u3001\u5b89\u88c5\u672c\u5730\u5305<\/h2>\n<pre><code class=\"language-shell line-numbers\">pip install -e .                     # \u9879\u76ee\u5728\u5f53\u524d\u76ee\u5f55\npip install -e path\/to\/project       # \u6307\u5b9a\u9879\u76ee\u7684\u76ee\u5f55\u8def\u5f84\n<\/code><\/pre>\n<h2>1.4\u3001\u4ece\u670d\u52a1\u5668\u6258\u7ba1\u7684\u5305\u4e2d\u5b89\u88c5<\/h2>\n<pre><code class=\"language-shell line-numbers\">pip install -e git+https:\/\/git.repo\/some_pkg.git#egg=SomePackage      # \u4ecegit\u5b89\u88c5\npip install -e svn+svn:\/\/svn.repo\/some_pkg\/trunk\/#egg=SomePackage  # \u4ecesvn\u5b89\u88c5\npip install -e git+https:\/\/git.repo\/some_pkg.git@feature#egg=SomePackage  # \u4ece\u4e00\u4e2a\u5206\u652f\u5b89\u88c5\npip install -e \"git+https:\/\/git.repo\/some_repo.git#egg=subdir&amp;subdirectory=subdir_path\"  # install a python package from a repo subdirectory\n<\/code><\/pre>\n<h3>\u4ece\u5176\u4ed6\u7d22\u5f15\u4e2d\uff08\u9664\u4e86PyPI\uff09\u5b89\u88c5\uff1a<\/h3>\n<pre><code class=\"language-shell line-numbers\">pip install --index-url http:\/\/my.package.repo\/simple\/ SomePackage\n<\/code><\/pre>\n<h3>\u5728\u5b89\u88c5\u671f\u95f4\u641c\u7d22\u5176\u4ed6\u7684\u7d22\u5f15\uff08\u9664\u4e86PyPI\uff09<\/h3>\n<pre><code class=\"language-shell line-numbers\">pip install --extra-index-url http:\/\/my.package.repo\/simple SomePackage\n<\/code><\/pre>\n<h2>1.5\u3001\u5347\u7ea7\u8f6f\u4ef6\u5305<\/h2>\n<p><em>pip\u5728\u5347\u7ea7\u8f6f\u4ef6\u5305\u4e4b\u524d\u4f1a\u81ea\u52a8\u5378\u8f7d\u65e7\u7684\u8f6f\u4ef6\u5305<\/em><\/p>\n<pre><code class=\"language-shell line-numbers\">pip install -U|--upgrade SomePackage\n<\/code><\/pre>\n<h1>2\u3001\u67e5\u770b\u5b89\u88c5\u7684\u5305<\/h1>\n<h2>2.1 \u4f7f\u7528 freeze \u683c\u5f0f\u5316\u8f93\u51fa\u5b89\u88c5\u7684\u5305<\/h2>\n<pre><code class=\"language-shell line-numbers\">pip freeze\n<\/code><\/pre>\n<h2>2.2 \u4f7f\u7528 list \u547d\u4ee4\u67e5\u770b\u5b89\u88c5\u7684\u7b2c\u4e09\u65b9\u5305<\/h2>\n<pre><code class=\"language-shell line-numbers\">pip list [--fromat (legacy|columns)]\n<\/code><\/pre>\n<h3>\u67e5\u770b\u54ea\u4e9b\u8f6f\u4ef6\u9700\u8981\u66f4\u65b0\uff08\u5217\u51fa\u8fc7\u65f6\u7684\u5305\uff09<\/h3>\n<pre><code class=\"language-shell line-numbers\">pip list -o|--outdated\n<\/code><\/pre>\n<h2>2.3 \u4f7f\u7528 show \u547d\u4ee4\u67e5\u770b\u5b89\u88c5\u7684\u5305\u7684\u8be6\u7ec6\u4fe1\u606f<\/h2>\n<pre><code class=\"language-shell line-numbers\">pip show SomePackage\n<\/code><\/pre>\n<h3>\u67e5\u770b\u5b89\u88c5\u5305\u7684\u5177\u4f53\u5b89\u88c5\u6587\u4ef6<\/h3>\n<pre><code class=\"language-shell line-numbers\">pip show -f|--files SomePackage\n<\/code><\/pre>\n<h1>3\u3001\u4f7f\u7528 uninstall \u547d\u4ee4\u5378\u8f7d\u8f6f\u4ef6\u5305<\/h1>\n<pre><code class=\"language-shell line-numbers\">pip uninstall Django\n<\/code><\/pre>\n<p><strong><em>\u4e5f\u53ef\u4ee5\u50cf\u5b89\u88c5\u5305\u4e00\u6837\uff0c\u5c06\u8981\u5378\u8f7d\u7684\u5305\u5199\u5165\u5230 uninstall.txt \u6587\u4ef6\u4e2d\uff0c\u7136\u540e\u4f7f\u7528 -r \u53c2\u6570\uff0c\u4e00\u6b21\u6027\u5378\u8f7d\u3002<\/em><\/strong><\/p>\n<h1>4\u3001\u4f7f\u7528 download \u547d\u4ee4\u4e0b\u8f7d\u8f6f\u4ef6\u5305<\/h1>\n<pre><code class=\"language-shell line-numbers\">pip download Django\n<\/code><\/pre>\n<h1>5\u3001\u4f7f\u7528 search \u547d\u4ee4\u5728PyPI\u4ed3\u5e93\u4e2d\u641c\u7d22\u8f6f\u4ef6\u5305<\/h1>\n<pre><code class=\"language-shell line-numbers\">pip search Django\n<\/code><\/pre>\n<h1>6\u3001\u4f7f\u7528 help \u547d\u4ee4\u67e5\u770bpip\u7684\u5e2e\u52a9\u624b\u518c<\/h1>\n<pre><code class=\"language-shell line-numbers\">pip help\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4f7f\u7528install\u547d\u4ee4\u5b89\u88c5\u5305 1.1\u3001\u5b89\u88c5PyPI\u5305 pip install SomePackage #  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[15],"tags":[412],"class_list":["post-775","post","type-post","status-publish","format-standard","hentry","category-15","tag-python"],"_links":{"self":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=775"}],"version-history":[{"count":1,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/775\/revisions"}],"predecessor-version":[{"id":776,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/775\/revisions\/776"}],"wp:attachment":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}