{"id":1161725,"date":"2025-01-13T19:19:49","date_gmt":"2025-01-13T11:19:49","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1161725.html"},"modified":"2025-01-13T19:19:52","modified_gmt":"2025-01-13T11:19:52","slug":"%e6%ba%90%e7%a0%81%e5%ae%89%e8%a3%85%e7%9a%84python%e5%a6%82%e4%bd%95%e5%88%a0%e9%99%a4","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1161725.html","title":{"rendered":"\u6e90\u7801\u5b89\u88c5\u7684python\u5982\u4f55\u5220\u9664"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25202933\/56577d5a-bd9e-426f-be33-d3c7a70dcf3f.webp\" alt=\"\u6e90\u7801\u5b89\u88c5\u7684python\u5982\u4f55\u5220\u9664\" \/><\/p>\n<p><p> \u6e90\u7801\u5b89\u88c5\u7684Python\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u5220\u9664\uff1a<strong>\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u3001\u5220\u9664\u73af\u5883\u53d8\u91cf\u3001\u6e05\u7406\u6b8b\u4f59\u6587\u4ef6<\/strong>\u3002\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u662f\u6700\u76f4\u63a5\u7684\u65b9\u5f0f\uff0c\u5177\u4f53\u65b9\u6cd5\u662f\u5728\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5Python\u65f6\uff0c\u901a\u5e38\u4f1a\u9009\u62e9\u4e00\u4e2a\u5b89\u88c5\u76ee\u5f55\uff0c\u53ea\u9700\u5220\u9664\u8be5\u76ee\u5f55\u5373\u53ef\u3002\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55<\/h3>\n<\/p>\n<p><p>\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u662f\u5220\u9664\u6e90\u7801\u5b89\u88c5\u7684Python\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002\u901a\u5e38\u5728\u7f16\u8bd1\u5b89\u88c5Python\u65f6\uff0c\u4f1a\u9009\u62e9\u4e00\u4e2a\u6307\u5b9a\u7684\u5b89\u88c5\u76ee\u5f55\u3002\u8981\u5220\u9664Python\uff0c\u53ef\u4ee5\u76f4\u63a5\u5220\u9664\u8be5\u76ee\u5f55\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u627e\u5230\u5b89\u88c5\u76ee\u5f55<\/strong>\uff1a\u5728\u7f16\u8bd1\u5b89\u88c5Python\u65f6\uff0c\u901a\u5e38\u4f1a\u4f7f\u7528<code>.\/configure --prefix=\/path\/to\/install<\/code>\u6307\u5b9a\u5b89\u88c5\u76ee\u5f55\u3002\u8bb0\u4f4f\u8fd9\u4e2a\u76ee\u5f55\u4f4d\u7f6e\u3002<\/li>\n<li><strong>\u5220\u9664\u76ee\u5f55<\/strong>\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982\u7ec8\u7aef\uff09\u8fdb\u5165\u4e0a\u7ea7\u76ee\u5f55\uff0c\u7136\u540e\u5220\u9664\u6307\u5b9a\u7684\u5b89\u88c5\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5b89\u88c5\u76ee\u5f55\u662f<code>\/usr\/local\/python3.8<\/code>\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5220\u9664\uff1a\n<pre><code class=\"language-sh\">sudo rm -rf \/usr\/local\/python3.8<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u68c0\u67e5\u662f\u5426\u5220\u9664\u5e72\u51c0<\/strong>\uff1a\u6267\u884c<code>python3 --version<\/code>\u6216<code>python --version<\/code>\u786e\u4fdd\u7cfb\u7edf\u627e\u4e0d\u5230\u5df2\u5220\u9664\u7684Python\u7248\u672c\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u5220\u9664\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5Python\u65f6\uff0c\u53ef\u80fd\u4f1a\u624b\u52a8\u6dfb\u52a0\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528Python\u547d\u4ee4\u3002\u5220\u9664\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\u53ef\u4ee5\u786e\u4fdd\u7cfb\u7edf\u4e0d\u518d\u4f7f\u7528\u5df2\u5220\u9664\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u6587\u4ef6<\/strong>\uff1a\u6253\u5f00\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6587\u4ef6\uff0c\u901a\u5e38\u662f<code>~\/.bashrc<\/code>\u3001<code>~\/.zshrc<\/code>\u6216<code>~\/.bash_profile<\/code>\u3002\n<pre><code class=\"language-sh\">nano ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u5220\u9664\u76f8\u5173\u914d\u7f6e<\/strong>\uff1a\u627e\u5230\u4e0ePython\u76f8\u5173\u7684\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u5e76\u5220\u9664\u3002\u4f8b\u5982\uff1a\n<pre><code class=\"language-sh\">export PATH=&quot;\/usr\/local\/python3.8\/bin:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u4fdd\u5b58\u5e76\u5237\u65b0\u914d\u7f6e<\/strong>\uff1a\u4fdd\u5b58\u6587\u4ef6\u5e76\u5237\u65b0\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u3002\n<pre><code class=\"language-sh\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u6e05\u7406\u6b8b\u4f59\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u548c\u73af\u5883\u53d8\u91cf\u540e\uff0c\u53ef\u80fd\u4f1a\u6709\u4e00\u4e9b\u6b8b\u4f59\u6587\u4ef6\u9700\u8981\u6e05\u7406\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5220\u9664\u7f16\u8bd1\u6587\u4ef6<\/strong>\uff1a\u7f16\u8bd1\u5b89\u88c5Python\u65f6\uff0c\u4f1a\u751f\u6210\u4e00\u4e9b\u4e34\u65f6\u6587\u4ef6\u548c\u76ee\u5f55\uff0c\u901a\u5e38\u5728\u6e90\u7801\u76ee\u5f55\u4e0b\u3002\u53ef\u4ee5\u8fdb\u5165\u6e90\u7801\u76ee\u5f55\u5e76\u5220\u9664\u8fd9\u4e9b\u6587\u4ef6\u3002\n<pre><code class=\"language-sh\">cd \/path\/to\/python-source<\/p>\n<p>sudo rm -rf build<\/p>\n<p>sudo rm -f config.log config.status<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u6e05\u7406\u7f13\u5b58<\/strong>\uff1a\u5220\u9664\u4e0ePython\u76f8\u5173\u7684\u7f13\u5b58\u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u4e8e<code>~\/.cache<\/code>\u76ee\u5f55\u4e0b\u3002\n<pre><code class=\"language-sh\">rm -rf ~\/.cache\/pip<\/p>\n<p>rm -rf ~\/.cache\/python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u68c0\u67e5\u5176\u4ed6\u7cfb\u7edf\u4f9d\u8d56<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\uff0cPython\u7684\u5b89\u88c5\u4f1a\u6d89\u53ca\u5230\u4e00\u4e9b\u7cfb\u7edf\u4f9d\u8d56\u5e93\uff0c\u8fd9\u4e9b\u5e93\u53ef\u80fd\u4f1a\u5728\u7cfb\u7edf\u4e2d\u4fdd\u7559\u3002\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\uff08\u5982<code>apt<\/code>\u3001<code>yum<\/code>\uff09\u68c0\u67e5\u5e76\u5220\u9664\u8fd9\u4e9b\u4f9d\u8d56\u5e93\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5217\u51faPython\u76f8\u5173\u5305<\/strong>\uff1a\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5217\u51fa\u4e0ePython\u76f8\u5173\u7684\u5305\u3002\n<pre><code class=\"language-sh\">dpkg -l | grep python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u5220\u9664\u76f8\u5173\u5305<\/strong>\uff1a\u6839\u636e\u5217\u51fa\u7684\u5305\u4fe1\u606f\uff0c\u5220\u9664\u4e0d\u518d\u9700\u8981\u7684Python\u76f8\u5173\u5305\u3002\n<pre><code class=\"language-sh\">sudo apt-get remove --purge python3.8<\/p>\n<p>sudo apt-get autoremove<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u6e90\u7801\u5b89\u88c5\u7684Python\u5220\u9664\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec\uff1a<strong>\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u3001\u5220\u9664\u73af\u5883\u53d8\u91cf\u3001\u6e05\u7406\u6b8b\u4f59\u6587\u4ef6<\/strong>\u3002\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u786e\u4fdd\u7cfb\u7edf\u4e2d\u4e0d\u518d\u5b58\u5728\u5df2\u5220\u9664\u7684Python\u7248\u672c\u3002\u5728\u8fdb\u884c\u5220\u9664\u64cd\u4f5c\u65f6\uff0c\u52a1\u5fc5\u5c0f\u5fc3\uff0c\u786e\u4fdd\u5220\u9664\u7684\u76ee\u5f55\u548c\u6587\u4ef6\u662f\u4e0ePython\u5b89\u88c5\u76f8\u5173\u7684\uff0c\u4ee5\u514d\u8bef\u5220\u91cd\u8981\u7684\u7cfb\u7edf\u6587\u4ef6\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5224\u65ad\u6211\u7684Python\u662f\u6e90\u7801\u5b89\u88c5\u7684\u8fd8\u662f\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\u5b89\u88c5\u7684\uff1f<\/strong><br \/>\u8981\u5224\u65ad\u60a8\u7684Python\u662f\u5426\u662f\u901a\u8fc7\u6e90\u7801\u5b89\u88c5\u7684\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5Python\u7684\u5b89\u88c5\u8def\u5f84\uff1a<code>which python<\/code> \u6216 <code>where python<\/code>\u3002\u5982\u679c\u8def\u5f84\u6307\u5411\u60a8\u624b\u52a8\u7f16\u8bd1\u7684\u76ee\u5f55\uff08\u901a\u5e38\u5728<code>\/usr\/local\/bin<\/code>\u6216\u7c7b\u4f3c\u7684\u4f4d\u7f6e\uff09\uff0c\u90a3\u4e48\u5b83\u53ef\u80fd\u662f\u6e90\u7801\u5b89\u88c5\u7684\u3002\u800c\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\u5b89\u88c5\u7684Python\u901a\u5e38\u4f4d\u4e8e\u7cfb\u7edf\u9ed8\u8ba4\u7684\u8def\u5f84\u4e0b\uff0c\u4f8b\u5982<code>\/usr\/bin\/python<\/code>\u3002<\/p>\n<p><strong>\u5220\u9664\u6e90\u7801\u5b89\u88c5\u7684Python\u4f1a\u5f71\u54cd\u7cfb\u7edf\u4e2d\u7684\u5176\u4ed6\u7a0b\u5e8f\u5417\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u5220\u9664\u7684\u662f\u7cfb\u7edf\u4e2d\u552f\u4e00\u7684Python\u7248\u672c\uff0c\u53ef\u80fd\u4f1a\u5f71\u54cd\u4f9d\u8d56\u4e8ePython\u7684\u5176\u4ed6\u7a0b\u5e8f\u6216\u811a\u672c\u3002\u56e0\u6b64\uff0c\u5728\u5220\u9664\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u6ca1\u6709\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u4f9d\u8d56\u4e8e\u8be5\u7248\u672c\u7684Python\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528<code>pip list<\/code>\u547d\u4ee4\u68c0\u67e5\u5df2\u5b89\u88c5\u7684Python\u5305\uff0c\u4e86\u89e3\u662f\u5426\u6709\u91cd\u8981\u7684\u4f9d\u8d56\u3002<\/p>\n<p><strong>\u5220\u9664\u6e90\u7801\u5b89\u88c5\u7684Python\u540e\uff0c\u5982\u4f55\u91cd\u65b0\u5b89\u88c5\u4e00\u4e2a\u65b0\u7684\u7248\u672c\uff1f<\/strong><br \/>\u5728\u5220\u9664\u6e90\u7801\u5b89\u88c5\u7684Python\u540e\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u901a\u8fc7\u5305\u7ba1\u7406\u5de5\u5177\uff08\u5982apt\u3001yum\u6216brew\uff09\u91cd\u65b0\u5b89\u88c5\u4e00\u4e2a\u65b0\u7684\u7248\u672c\uff0c\u6216\u8005\u518d\u6b21\u4ece\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u3002\u82e5\u9009\u62e9\u6e90\u7801\u5b89\u88c5\uff0c\u8bf7\u786e\u4fdd\u4e0b\u8f7d\u6700\u65b0\u7684Python\u6e90\u4ee3\u7801\uff0c\u89e3\u538b\u5e76\u6309\u7167\u5176\u4e2d\u7684<code>README<\/code>\u6216<code>INSTALL<\/code>\u6587\u4ef6\u4e2d\u7684\u8bf4\u660e\u8fdb\u884c\u7f16\u8bd1\u548c\u5b89\u88c5\u3002\u786e\u4fdd\u914d\u7f6e\u597d\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u5728\u7ec8\u7aef\u4e2d\u987a\u5229\u8c03\u7528\u65b0\u7248\u672c\u7684Python\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u6e90\u7801\u5b89\u88c5\u7684Python\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u5220\u9664\uff1a\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55\u3001\u5220\u9664\u73af\u5883\u53d8\u91cf\u3001\u6e05\u7406\u6b8b\u4f59\u6587\u4ef6\u3002\u624b\u52a8\u5220\u9664\u5b89\u88c5\u76ee\u5f55 [&hellip;]","protected":false},"author":3,"featured_media":1161727,"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\/1161725"}],"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=1161725"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1161725\/revisions"}],"predecessor-version":[{"id":1161730,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1161725\/revisions\/1161730"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1161727"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1161725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1161725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1161725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}