{"id":939721,"date":"2024-12-26T20:41:46","date_gmt":"2024-12-26T12:41:46","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/939721.html"},"modified":"2024-12-26T20:41:48","modified_gmt":"2024-12-26T12:41:48","slug":"python%e5%a6%82%e4%bd%95%e5%8d%b8%e8%bd%bdpip","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/939721.html","title":{"rendered":"python\u5982\u4f55\u5378\u8f7dpip"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25074625\/6781a088-0b32-4752-86dd-763c6eec2315.webp\" alt=\"python\u5982\u4f55\u5378\u8f7dpip\" \/><\/p>\n<p><p> \u8981\u5378\u8f7dPython\u4e2d\u7684pip\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff1a<strong>\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u3001\u76f4\u63a5\u5220\u9664pip\u6587\u4ef6\u3001\u4f7f\u7528Python\u81ea\u5e26\u7684ensurepip\u6a21\u5757<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u662f\u6700\u4e3a\u63a8\u8350\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u81ea\u52a8\u5904\u7406\u76f8\u5173\u4f9d\u8d56\u5173\u7cfb\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u5378\u8f7dpip\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668<\/h3>\n<\/p>\n<ol>\n<li><strong>\u9002\u7528\u4e8eLinux\u7528\u6237<\/strong><\/li>\n<\/ol>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u5f88\u591aPython\u73af\u5883\u548cpip\u90fd\u662f\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u7684\uff0c\u5982apt\u3001yum\u7b49\u3002\u8981\u5378\u8f7dpip\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5bf9\u4e8eDebian\u7cfb\uff08\u5982Ubuntu\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get remove python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u4e8eRed Hat\u7cfb\uff08\u5982CentOS\uff09\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum remove python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u5378\u8f7dpip\uff0c\u4f1a\u81ea\u52a8\u5904\u7406\u4e0epip\u76f8\u5173\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u786e\u4fdd\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u9002\u7528\u4e8emacOS\u7528\u6237<\/strong><\/li>\n<\/ol>\n<p><p>macOS\u7528\u6237\u901a\u5e38\u4f7f\u7528Homebrew\u6765\u7ba1\u7406\u8f6f\u4ef6\u5305\u3002\u5982\u679cpip\u662f\u901a\u8fc7Homebrew\u5b89\u88c5\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5378\u8f7d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew uninstall pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u9ad8\u6548\uff0c\u9002\u5408\u5927\u591a\u6570macOS\u7528\u6237\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u76f4\u63a5\u5220\u9664pip\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5982\u679cpip\u662f\u901a\u8fc7get-pip.py\u811a\u672c\u5355\u72ec\u5b89\u88c5\u7684\uff0c\u53ef\u4ee5\u624b\u52a8\u5220\u9664\u76f8\u5e94\u7684pip\u6587\u4ef6\u548c\u76f8\u5173\u76ee\u5f55\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u5408\u90a3\u4e9b\u624b\u52a8\u5b89\u88c5pip\u800c\u4e0d\u5e0c\u671b\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u7684\u7528\u6237\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u627e\u5230pip\u7684\u5b89\u88c5\u8def\u5f84<\/strong><\/li>\n<\/ol>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u627e\u5230pip\u7684\u5b89\u88c5\u8def\u5f84\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u83b7\u53d6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">which pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u663e\u793apip\u7684\u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u3002\u901a\u5e38\u662f\u5728<code>\/usr\/local\/bin\/pip<\/code>\u6216<code>\/usr\/bin\/pip<\/code>\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5220\u9664pip\u53ef\u6267\u884c\u6587\u4ef6<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664pip\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo rm \/usr\/local\/bin\/pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u4f60\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u8def\u5f84\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u5220\u9664pip\u76f8\u5173\u76ee\u5f55<\/strong><\/li>\n<\/ol>\n<p><p>pip\u7684\u5e93\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8ePython\u7684<code>site-packages<\/code>\u76ee\u5f55\u4e2d\u3002\u627e\u5230\u5e76\u5220\u9664\u8fd9\u4e9b\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo rm -rf \/usr\/local\/lib\/python3.x\/site-packages\/pip*<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u786e\u4fdd\u66ff\u6362<code>python3.x<\/code>\u4e3a\u4f60\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Python\u81ea\u5e26\u7684ensurepip\u6a21\u5757<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u5e0c\u671b\u901a\u8fc7Python\u81ea\u5e26\u7684\u529f\u80fd\u6765\u5378\u8f7dpip\uff0c\u53ef\u4ee5\u4f7f\u7528ensurepip\u6a21\u5757\u3002\u786e\u4fdd\u4f60\u4e86\u89e3\u8fd9\u6837\u505a\u7684\u540e\u679c\uff0c\u56e0\u4e3a\u5b83\u53ef\u80fd\u4f1a\u5f71\u54cd\u4f60\u7684Python\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u7981\u7528ensurepip<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u53ea\u60f3\u7981\u7528pip\u800c\u4e0d\u662f\u5b8c\u5168\u5378\u8f7d\u3002\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u6216\u8c03\u6574Python\u914d\u7f6e\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u91cd\u65b0\u5b89\u88c5Python<\/strong><\/li>\n<\/ol>\n<p><p>\u5982\u679c\u6ca1\u6709\u5176\u4ed6\u9009\u62e9\uff0c\u91cd\u65b0\u5b89\u88c5Python\u53ef\u4ee5\u5b8c\u5168\u79fb\u9664pip\u3002\u7136\u800c\uff0c\u8fd9\u53ef\u80fd\u4e0d\u662f\u6700\u4f18\u89e3\uff0c\u56e0\u4e3a\u5b83\u4f1a\u5f71\u54cd\u5230\u6240\u6709\u4f9d\u8d56\u4e8e\u5f53\u524dPython\u7248\u672c\u7684\u9879\u76ee\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5378\u8f7d\u540e\u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<ol>\n<li><strong>\u6e05\u7406\u6b8b\u7559\u6587\u4ef6<\/strong><\/li>\n<\/ol>\n<p><p>\u5728\u5378\u8f7dpip\u540e\uff0c\u68c0\u67e5\u5e76\u6e05\u7406\u4efb\u4f55\u53ef\u80fd\u7684\u6b8b\u7559\u6587\u4ef6\uff0c\u4ee5\u786e\u4fdd\u7cfb\u7edf\u7684\u5e72\u51c0\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u68c0\u67e5Python\u73af\u5883<\/strong><\/li>\n<\/ol>\n<p><p>\u5378\u8f7dpip\u53ef\u80fd\u4f1a\u5f71\u54cd\u5230\u5176\u4ed6\u4f9d\u8d56\u4e8epip\u7684Python\u5de5\u5177\u548c\u5e93\u3002\u5378\u8f7d\u540e\uff0c\u5efa\u8bae\u68c0\u67e5\u548c\u6d4b\u8bd5\u4f60\u7684Python\u73af\u5883\uff0c\u786e\u4fdd\u5176\u4ed6\u529f\u80fd\u6b63\u5e38\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u8003\u8651\u865a\u62df\u73af\u5883<\/strong><\/li>\n<\/ol>\n<p><p>\u5982\u679c\u4f60\u7ecf\u5e38\u9700\u8981\u5b89\u88c5\u548c\u5378\u8f7dpip\u6216\u5176\u4ed6Python\u5e93\uff0c\u8003\u8651\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002\u865a\u62df\u73af\u5883\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u907f\u514d\u5168\u5c40Python\u73af\u5883\u7684\u6df7\u4e71\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u6709\u6548\u5730\u5378\u8f7dPython\u4e2d\u7684pip\u3002\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u5b89\u88c5\u65b9\u5f0f\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u786e\u4fdd\u4f60\u7684\u7cfb\u7edf\u7a33\u5b9a\u4e14\u529f\u80fd\u5b8c\u6574\u3002\u5982\u679c\u5c06\u6765\u9700\u8981\u91cd\u65b0\u5b89\u88c5pip\uff0c\u53ef\u4ee5\u4f7f\u7528get-pip.py\u811a\u672c\u6216\u76f8\u5e94\u7684\u5305\u7ba1\u7406\u5668\u8f7b\u677e\u5b8c\u6210\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5224\u65ad\u6211\u7684Python\u73af\u5883\u4e2d\u662f\u5426\u5b89\u88c5\u4e86pip\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>pip --version<\/code>\u6216<code>pip3 --version<\/code>\u6765\u68c0\u67e5pip\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5982\u679cpip\u5df2\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u8fd4\u56de\u7248\u672c\u4fe1\u606f\uff1b\u5982\u679c\u672a\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230\u76f8\u5173\u7684\u9519\u8bef\u63d0\u793a\u3002<\/p>\n<p><strong>\u5378\u8f7dpip\u4f1a\u5f71\u54cd\u6211\u7684Python\u9879\u76ee\u5417\uff1f<\/strong><br \/>\u5378\u8f7dpip\u4f1a\u5bfc\u81f4\u60a8\u65e0\u6cd5\u4f7f\u7528pip\u6765\u5b89\u88c5\u6216\u7ba1\u7406Python\u5305\u3002\u8fd9\u610f\u5473\u7740\u60a8\u4e4b\u524d\u901a\u8fc7pip\u5b89\u88c5\u7684\u5e93\u5c06\u65e0\u6cd5\u66f4\u65b0\u6216\u5378\u8f7d\uff0c\u53ef\u80fd\u4f1a\u5f71\u54cd\u4f9d\u8d56\u4e8e\u8fd9\u4e9b\u5e93\u7684\u9879\u76ee\u3002\u56e0\u6b64\uff0c\u5efa\u8bae\u5728\u5378\u8f7d\u524d\u786e\u8ba4\u662f\u5426\u6709\u5fc5\u8981\uff0c\u5e76\u8003\u8651\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u5378\u8f7d\u4e86pip\uff0c\u5982\u4f55\u91cd\u65b0\u5b89\u88c5\u5b83\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u5378\u8f7d\u4e86pip\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u91cd\u65b0\u5b89\u88c5\uff1a\u4f7f\u7528Python\u7684\u5b98\u65b9\u5b89\u88c5\u5305\uff0c\u6216\u8005\u4e0b\u8f7d<code>get-pip.py<\/code>\u811a\u672c\u5e76\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>python get-pip.py<\/code>\u3002\u6b64\u5916\uff0c\u4e00\u4e9bPython\u53d1\u884c\u7248\uff08\u5982Anaconda\uff09\u53ef\u80fd\u81ea\u5e26pip\uff0c\u60a8\u4e5f\u53ef\u4ee5\u9009\u62e9\u91cd\u65b0\u5b89\u88c5\u8fd9\u4e9b\u53d1\u884c\u7248\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5378\u8f7dPython\u4e2d\u7684pip\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u5b9e\u73b0\uff1a\u4f7f\u7528\u7cfb\u7edf\u5305\u7ba1\u7406\u5668\u3001\u76f4\u63a5\u5220\u9664pip\u6587\u4ef6\u3001\u4f7f\u7528Python [&hellip;]","protected":false},"author":3,"featured_media":939725,"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\/939721"}],"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=939721"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/939721\/revisions"}],"predecessor-version":[{"id":939726,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/939721\/revisions\/939726"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/939725"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=939721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=939721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=939721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}