{"id":1257,"date":"2020-05-20T16:14:27","date_gmt":"2020-05-20T08:14:27","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1257"},"modified":"2020-05-20T16:14:27","modified_gmt":"2020-05-20T08:14:27","slug":"python-pip%e5%8c%85%e7%ae%a1%e7%90%86%e5%99%a8%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1257","title":{"rendered":"Python pip\u5305\u7ba1\u7406\u5668\u4ecb\u7ecd"},"content":{"rendered":"<p style=\\\"padding-left: 40px;\\\">\u00a0 \u00a0 \u00a0 \u00a0pip\u662f\u4e00\u4e2a\u4ee5Python\u8ba1\u7b97\u673a\u7a0b\u5e8f\u8bed\u8a00\u5199\u6210\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u7cfb\u7edf\uff0c\u4ed6\u53ef\u4ee5\u5b89\u88c5\u548c\u7ba1\u7406\u8f6f\u4ef6\u5305\uff0c\u4e5f\u53ef\u4ee5\u5728\u201cPython\u8f6f\u4ef6\u5305\u7d22\u5f15\u201d\uff08Python Package Index\uff0c\u7b80\u79f0PyPI\uff09\u67e5\u627e\u3002Python\u5b89\u88c5\u5305\u7684\u5de5\u5177\u6709easy_install, setuptools, pip\uff0cdistribute\u7b49\u3002\u5176\u4e2ddistribute\u662fsetuptools\u7684\u66ff\u4ee3\u54c1\uff0c\u662f\u5bf9\u6807\u51c6\u5e93disutils\u6a21\u5757\u7684\u589e\u5f3a\uff0cdisutils\u4e3b\u8981\u662f\u7528\u6765\u66f4\u52a0\u5bb9\u6613\u7684\u6253\u5305\u548c\u5206\u53d1\u5305\uff0c\u7279\u522b\u662f\u5bf9\u5176\u4ed6\u7684\u5305\u6709\u4f9d\u8d56\u7684\u5305\u3002distribute\u88ab\u521b\u5efa\u662f\u56e0\u4e3aSetuptools\u5305\u4e0d\u518d\u7ef4\u62a4\u3002\u800cpip\u662feasy_install\u7684\u66ff\u4ee3\u54c1\u3002<\/p>\n<ul>\n<li><strong>\u5b89\u88c5pip<\/strong><\/li>\n<\/ul>\n<pre>yum install python-pip<\/pre>\n<ul>\n<li>\u663e\u793a\u7248\u672c\u548c\u8def\u5f84<\/li>\n<\/ul>\n<pre style=\\\"padding-left: 40px;\\\">pip --version<\/pre>\n<ul>\n<li><strong>\u5347\u7ea7pip<\/strong><\/li>\n<\/ul>\n<pre>pip install -U pip<\/pre>\n<ul>\n<li><strong>pip\u5305\u7ba1\u7406<\/strong><\/li>\n<\/ul>\n<p style=\\\"padding-left: 40px;\\\">\u6307\u5b9a\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\u7248\u672c\uff0c\u901a\u8fc7\u4f7f\u7528 ==\u3001&gt;=\u3001&lt;=\u3001&gt;\u3001&lt; \u6765\u6307\u5b9a\u4e00\u4e2a\u7248\u672c\u53f7\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<pre style=\\\"padding-left: 40px;\\\">pip install markdown\npip install markdown==2.0<\/pre>\n<ul>\n<li><strong>\u5347\u7ea7\u6307\u5b9a\u5b89\u88c5\u5305<\/strong><\/li>\n<\/ul>\n<p style=\\\"padding-left: 40px;\\\">\u5c06\u5305\u5347\u7ea7\u5230\u5f53\u524d\u6700\u65b0\u7684\u7248\u672c\uff0c\u4f7f\u7528\u53c2\u6570 -U \u6216\u8005 &#8211;upgrade<\/p>\n<pre style=\\\"padding-left: 40px;\\\">pip install -U package_name<\/pre>\n<ul>\n<li><strong>\u641c\u7d22\u5305\uff1a<\/strong><\/li>\n<\/ul>\n<pre style=\\\"padding-left: 40px;\\\">pip search \\\"package_name\\\"<\/pre>\n<ul>\n<li><strong>\u5217\u51fa\u5df2\u5b89\u88c5\u7684\u5305\uff1a<\/strong><\/li>\n<\/ul>\n<p style=\\\"padding-left: 40px;\\\">pip list \u548cpip freeze\u4e24\u8005\u90fd\u662f\u5217\u51fa\u5df2\u7ecf\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\uff0cpip list\u5217\u51fa\u4e86\u6240\u6709\u7684\u5305\uff0cpip freeze \u53ea\u5217\u51fa\u7531pip \u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\uff0c\u5e76\u8f93\u51fa\u6210requirements format\u683c\u5f0f\u3002<span style=\\\"font-size: 1rem;\\\">requirements.txt\u6709\u4e00\u4e2a\u56fa\u5b9a\u7684\u683c\u5f0f\uff1a\u8f6f\u4ef6\u5305\u540d==\u7248\u672c\u53f7\uff0c\u6bcf\u884c\u4ee3\u8868\u4e00\u4e2a\u8f6f\u4ef6\u5305\u3002\u5982 django==1.11.29\u3002\u5982\u679c\u6362\u4e00\u4e2a\u65b0\u7684\u73af\u5883\u9700\u8981\u5b89\u88c5\u4e00\u4e2a\u76f8\u540c\u7684python\u73af\u5883\uff0c\u90a3\u4e48\u53ea\u9700\u8981\u6709requirements.txt\u6587\u4ef6\u5373\u53ef\u5feb\u901f\u5b89\u88c5\uff0c\u5c31\u4e0d\u9700\u8981\u89e3\u51b3\u8f6f\u4ef6\u5305\u4f9d\u8d56\u7684\u5173\u7cfb\u4e86\u3002<\/span><\/p>\n<p style=\\\"padding-left: 40px;\\\"><strong><span style=\\\"font-size: 1rem;\\\">\u5bfc\u51fa\u8f6f\u4ef6\u5305\u5230\u6587\u4ef6<\/span><\/strong><\/p>\n<pre style=\\\"padding-left: 40px;\\\">pip freeze &gt; requirements.txt<\/pre>\n<p style=\\\"padding-left: 40px;\\\"><strong>\u8f6f\u4ef6\u5305\u5bfc\u5165\u5b89\u88c5<\/strong><\/p>\n<pre style=\\\"padding-left: 40px;\\\">pip install -r requirements.txt<\/pre>\n<ul>\n<li><strong>\u5378\u8f7d\u5305<\/strong><\/li>\n<\/ul>\n<pre style=\\\"padding-left: 40px;\\\">pip uninstall package_name<\/pre>\n<ul>\n<li><strong>\u663e\u793a\u5305\u6587\u4ef6<\/strong><\/li>\n<\/ul>\n<p style=\\\"padding-left: 40px;\\\">\u663e\u793a\u5305\u7684\u7b80\u4ecb\u3001\u5b89\u88c5\u7684\u4f4d\u7f6e\uff0c\u4ee5\u53ca\u6574\u4e2a\u5305\u5305\u542b\u7684\u6587\u4ef6\u3002<\/p>\n<pre style=\\\"padding-left: 40px;\\\">pip show --files PackageName<\/pre>\n<ul>\n<li><strong>\u663e\u793a\u8fc7\u671f\u7684\u5305\uff0c\u5217\u51fa\u6240\u6709\u53ef\u4ee5\u66f4\u65b0\u7684\u5305\u3002<\/strong><\/li>\n<\/ul>\n<pre style=\\\"padding-left: 40px;\\\">pip list --outdated\npip list -o<\/pre>\n<ul>\n<li><strong>\u6307\u5b9aPyPI\u5e93\u4e0b\u8f7d\u8f6f\u4ef6\u5305<\/strong><\/li>\n<\/ul>\n<pre style=\\\"padding-left: 40px;\\\">pip install -i http:\/\/pypi.douban.com\/simple --trusted-host pypi.douban.com <strong>packagename<\/strong><\/pre>\n<ul>\n<li>\u4e0b\u8f7d\u5305\u4f46\u4e0d\u5b89\u88c5\uff1a<\/li>\n<\/ul>\n<pre style=\\\"padding-left: 40px;\\\">pip install <strong>packagename<\/strong> -d \u76ee\u5f55<\/pre>\n<ul>\n<li>\u6253\u5305<\/li>\n<\/ul>\n<pre style=\\\"padding-left: 40px;\\\">pip wheel <strong>packagename<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 \u00a0 \u00a0pip\u662f\u4e00\u4e2a\u4ee5Python\u8ba1\u7b97\u673a\u7a0b\u5e8f\u8bed\u8a00\u5199\u6210\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u7cfb\u7edf\uff0c\u4ed6\u53ef\u4ee5\u5b89\u88c5\u548c\u7ba1\u7406\u8f6f\u4ef6\u5305\uff0c\u4e5f\u53ef\u4ee5\u5728\u201c &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1257\"> <span class=\"screen-reader-text\">Python pip\u5305\u7ba1\u7406\u5668\u4ecb\u7ecd<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","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":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[106],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"\u00a0 \u00a0 \u00a0 \u00a0pip\u662f\u4e00\u4e2a\u4ee5Python\u8ba1\u7b97\u673a\u7a0b\u5e8f\u8bed\u8a00\u5199\u6210\u7684\u8f6f\u4ef6\u5305\u7ba1\u7406\u7cfb\u7edf\uff0c\u4ed6\u53ef\u4ee5\u5b89\u88c5\u548c\u7ba1\u7406\u8f6f\u4ef6\u5305\uff0c\u4e5f\u53ef\u4ee5\u5728\u201c&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1257"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1257"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1257\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1257"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}