{"id":1011548,"date":"2024-12-27T11:30:53","date_gmt":"2024-12-27T03:30:53","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1011548.html"},"modified":"2024-12-27T11:30:57","modified_gmt":"2024-12-27T03:30:57","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e4%b8%8b%e8%bd%bdpip","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1011548.html","title":{"rendered":"\u5982\u4f55\u7528python\u4e0b\u8f7dpip"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25085634\/83319f3b-9051-4f82-8c79-65c3feeafabb.webp\" alt=\"\u5982\u4f55\u7528python\u4e0b\u8f7dpip\" \/><\/p>\n<p><p> <strong>\u8981\u7528Python\u4e0b\u8f7dpip\uff0c\u53ef\u4ee5\u901a\u8fc7Python\u7684\u5185\u7f6e\u5de5\u5177\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u4e2d\u5305\u542bpip\u3001\u4f7f\u7528get-pip.py\u811a\u672c\u3001\u901a\u8fc7Python\u53d1\u884c\u7248\u5b89\u88c5\u7a0b\u5e8f\u6216\u5305\u7ba1\u7406\u5668\u81ea\u52a8\u5b89\u88c5pip<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528<code>get-pip.py<\/code>\u811a\u672c\u662f\u6700\u5e38\u89c1\u548c\u76f4\u63a5\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u8fd9\u4e2a\u811a\u672c\u4f1a\u81ea\u52a8\u4e3a\u4f60\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684pip\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6765\u786e\u8ba4Python\u662f\u5426\u5df2\u5b89\u88c5\u4ee5\u53ca\u5176\u7248\u672c\u53f7\u3002\u5982\u679c\u8fd8\u6ca1\u6709\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u4ece<a href=\"https:\/\/www.python.org\/downloads\/\">Python\u5b98\u65b9\u7f51\u7ad9<\/a>\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u901a\u8fc7get-pip.py\u811a\u672c\u5b89\u88c5pip<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dget-pip.py<\/strong><\/p>\n<\/p>\n<p><p>\u8bbf\u95ee<code>https:\/\/bootstrap.pypa.io\/get-pip.py<\/code>\u4e0b\u8f7d<code>get-pip.py<\/code>\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528\u6d4f\u89c8\u5668\u76f4\u63a5\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u4f7f\u7528<code>curl<\/code>\u6216<code>wget<\/code>\u547d\u4ee4\u4e0b\u8f7d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">curl https:\/\/bootstrap.pypa.io\/get-pip.py -o get-pip.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">wget https:\/\/bootstrap.pypa.io\/get-pip.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cget-pip.py<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u884c\u5de5\u5177\uff08Windows\u4e0a\u7684cmd\u6216PowerShell\uff0cmacOS\u548cLinux\u4e0a\u7684\u7ec8\u7aef\uff09\uff0c\u5bfc\u822a\u5230<code>get-pip.py<\/code>\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python get-pip.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u6267\u884c\u811a\u672c\u5e76\u5b89\u88c5pip\u3002\u5982\u679c\u4f60\u6709\u591a\u4e2aPython\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528<code>python3 get-pip.py<\/code>\u6765\u6307\u5b9a\u4f7f\u7528Python 3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1pip\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9a8c\u8bc1pip\u662f\u5426\u6210\u529f\u5b89\u88c5\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bpip\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u4f60\u5e94\u8be5\u4f1a\u770b\u5230pip\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Python\u53d1\u884c\u7248\u81ea\u5e26\u7684\u5b89\u88c5\u5de5\u5177<\/h3>\n<\/p>\n<p><p>\u4e00\u4e9bPython\u7684\u53d1\u884c\u7248\uff0c\u5982Anaconda\u6216ActivePython\uff0c\u81ea\u5e26\u4e86pip\u7684\u5b89\u88c5\u5305\u3002\u5728\u5b89\u88c5\u8fd9\u4e9b\u53d1\u884c\u7248\u65f6\uff0cpip\u4f1a\u81ea\u52a8\u5b89\u88c5\uff0c\u65e0\u9700\u989d\u5916\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fLinux\u7cfb\u7edf\uff0c\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u81ea\u5e26\u7684\u5305\u7ba1\u7406\u5668\u5b89\u88c5pip\u3002\u4f8b\u5982\uff0c\u5728Debian\u7cfb\u7684Linux\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo apt update<\/p>\n<p>sudo apt install python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5b89\u88c5Python 3\u7248\u672c\u7684pip\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u624b\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5b89\u88c5pip\u540e\u53ef\u80fd\u9700\u8981\u624b\u52a8\u5c06pip\u7684\u53ef\u6267\u884c\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u89e3\u51b3\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u627e\u5230pip\u7684\u5b89\u88c5\u8def\u5f84<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u627e\u5230pip\u7684\u5b89\u88c5\u8def\u5f84\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">where pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793apip\u7684\u5b8c\u6574\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<\/p>\n<p><p>\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e0b\u627e\u5230\u201cPath\u201d\u53d8\u91cf\u5e76\u7f16\u8f91\uff0c\u6dfb\u52a0pip\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/li>\n<\/ul>\n<p><p>\u5728macOS\u548cLinux\u4e0a\uff0c\u53ef\u4ee5\u7f16\u8f91<code>~\/.bashrc<\/code>\u6216<code>~\/.bash_profile<\/code>\uff08\u6839\u636e\u4f60\u4f7f\u7528\u7684shell\u4e0d\u540c\uff09\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">export PATH=$PATH:\/path\/to\/pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u8fd0\u884c<code>source ~\/.bashrc<\/code>\u6216<code>source ~\/.bash_profile<\/code>\u4f7f\u5176\u751f\u6548\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6848<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5pip\u6216\u4f7f\u7528pip\u5b89\u88c5\u8f6f\u4ef6\u5305\u65f6\u53ef\u80fd\u4f1a\u9047\u5230\u6743\u9650\u95ee\u9898\u3002\u53ef\u4ee5\u4f7f\u7528<code>sudo<\/code>\u547d\u4ee4\u5728Linux\u548cmacOS\u4e0a\u6216\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\u5728Windows\u4e0a\u89e3\u51b3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f51\u7edc\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u7f51\u7edc\u4e0d\u7a33\u5b9a\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25\u3002\u53ef\u4ee5\u5c1d\u8bd5\u591a\u6b21\u8fd0\u884c\u5b89\u88c5\u547d\u4ee4\uff0c\u6216\u5728\u7f51\u7edc\u72b6\u51b5\u8f83\u597d\u7684\u65f6\u5019\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7248\u672c\u51b2\u7a81<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4pip\u7248\u672c\u51b2\u7a81\u6216\u8def\u5f84\u95ee\u9898\u3002\u53ef\u4ee5\u4f7f\u7528<code>python3 -m pip<\/code>\u6765\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7248\u672c\u7684pip\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5e94\u8be5\u80fd\u591f\u6210\u529f\u4e0b\u8f7d\u548c\u5b89\u88c5pip\uff0c\u5e76\u5f00\u59cb\u7ba1\u7406\u4f60\u7684Python\u5305\u3002\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u914d\u7f6e\u6b63\u786e\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u65f6\u5feb\u901f\u5b89\u88c5\u548c\u66f4\u65b0\u8f6f\u4ef6\u5305\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5224\u65ad\u6211\u7684\u7cfb\u7edf\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86pip\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>pip --version<\/code>\u6765\u68c0\u67e5\u7cfb\u7edf\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86pip\u3002\u5982\u679c\u5df2\u7ecf\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u663e\u793apip\u7684\u7248\u672c\u4fe1\u606f\uff1b\u5982\u679c\u672a\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u627e\u4e0d\u5230\u8be5\u547d\u4ee4\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u7684Python\u7248\u672c\u8f83\u65e7\uff0c\u5982\u4f55\u786e\u4fddpip\u80fd\u6b63\u5e38\u5b89\u88c5\uff1f<\/strong><br \/>\u5bf9\u4e8ePython 3.4\u53ca\u66f4\u65e9\u7248\u672c\uff0cpip\u901a\u5e38\u4e0d\u4f1a\u81ea\u5e26\u5b89\u88c5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0b\u8f7d<code>get-pip.py<\/code>\u811a\u672c\u6765\u5b89\u88c5\u3002\u53ea\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>python get-pip.py<\/code>\u5373\u53ef\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5b89\u88c5pip\u540e\uff0c\u5982\u4f55\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\uff1f<\/strong><br \/>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>pip install --upgrade pip<\/code>\u53ef\u4ee5\u5c06pip\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u786e\u4fdd\u5728\u6267\u884c\u8be5\u547d\u4ee4\u65f6\u4f7f\u7528\u5177\u6709\u7ba1\u7406\u5458\u6743\u9650\u7684\u7ec8\u7aef\uff0c\u4ee5\u907f\u514d\u6743\u9650\u95ee\u9898\u3002<\/p>\n<p><strong>\u5982\u679c\u5728\u5b89\u88c5pip\u65f6\u9047\u5230\u9519\u8bef\uff0c\u6211\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5b89\u88c5\u65f6\u53ef\u80fd\u4f1a\u51fa\u73b0\u5404\u79cd\u9519\u8bef\uff0c\u5e38\u89c1\u7684\u5305\u62ec\u7f51\u7edc\u95ee\u9898\u6216\u6743\u9650\u4e0d\u8db3\u3002\u5efa\u8bae\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\uff0c\u786e\u4fdd\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5305\u7d22\u5f15\u3002\u5982\u679c\u95ee\u9898\u4f9d\u65e7\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u884c\uff0c\u6216\u67e5\u770b\u9519\u8bef\u4fe1\u606f\u4ee5\u83b7\u53d6\u66f4\u5177\u4f53\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u7528Python\u4e0b\u8f7dpip\uff0c\u53ef\u4ee5\u901a\u8fc7Python\u7684\u5185\u7f6e\u5de5\u5177\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u4e2d\u5305\u542bpip\u3001\u4f7f\u7528get-p [&hellip;]","protected":false},"author":3,"featured_media":1011556,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1011548"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1011548"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1011548\/revisions"}],"predecessor-version":[{"id":1011561,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1011548\/revisions\/1011561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1011556"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1011548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1011548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1011548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}