{"id":150132,"date":"2024-05-06T10:55:35","date_gmt":"2024-05-06T02:55:35","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/150132.html"},"modified":"2024-05-06T10:55:37","modified_gmt":"2024-05-06T02:55:37","slug":"mac%e6%80%8e%e4%b9%88%e5%8d%b8%e8%bd%bdpython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/150132.html","title":{"rendered":"mac\u600e\u4e48\u5378\u8f7dpython"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27143711\/2681ab55-4605-4c69-a0a9-760c12b12680.webp\" alt=\"mac\u600e\u4e48\u5378\u8f7dpython\" \/><\/p>\n<p><p>\u5378\u8f7dMac\u4e0a\u7684Python\u901a\u5e38\u6d89\u53ca\u5230\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff0c\u5305\u62ec<strong>\u786e\u5b9aPython\u7684\u7248\u672c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u3001\u624b\u52a8\u5220\u9664\u76f8\u5173\u6587\u4ef6\u548c\u6e05\u7406\u73af\u5883\u8def\u5f84<\/strong>\u3002\u8fd9\u4e9b\u6b65\u9aa4\u80fd\u591f\u786e\u4fdd\u5f7b\u5e95\u4e14\u5b89\u5168\u5730\u4ece\u7cfb\u7edf\u4e2d\u79fb\u9664Python\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u91cd\u70b9\u4ecb\u7ecd<strong>\u4f7f\u7528\u547d\u4ee4\u884c<\/strong>\u8fd9\u4e00\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u547d\u4ee4\u884c\u662f\u5378\u8f7dMac\u4e0aPython\u6700\u76f4\u63a5\u4e5f\u662f\u6700\u9ad8\u6548\u7684\u65b9\u6cd5\u3002\u5b83\u5141\u8bb8\u7528\u6237\u7cbe\u786e\u5730\u6307\u660e\u8981\u5220\u9664\u7684Python\u7248\u672c\uff0c\u5e76\u4e14\u51e0\u4e4e\u4e0d\u4f1a\u7559\u4e0b\u4efb\u4f55\u6b8b\u4f59\u6587\u4ef6\u3002\u8be5\u65b9\u6cd5\u9700\u8981\u7528\u6237\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u7279\u5b9a\u7684\u547d\u4ee4\uff0c\u4ece\u800c\u79fb\u9664\u7cfb\u7edf\u4e2d\u5b89\u88c5\u7684Python\u3002\u8fd9\u79cd\u65b9\u5f0f\u7279\u522b\u9002\u7528\u4e8e\u90a3\u4e9b\u5b89\u88c5\u4e86\u591a\u4e2aPython\u7248\u672c\uff0c\u9700\u8981\u7cbe\u786e\u63a7\u5236\u5378\u8f7d\u8fc7\u7a0b\u7684\u7528\u6237\u3002\u63a5\u4e0b\u6765\uff0c\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u7ec8\u7aef\u7cbe\u786e\u5730\u5378\u8f7dPython\uff0c\u4ee5\u53ca\u5982\u4f55\u6267\u884c\u540e\u7eed\u7684\u6e05\u7406\u5de5\u4f5c\u4ee5\u786e\u4fdd\u7cfb\u7edf\u7684\u6574\u6d01\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u786e\u5b9aPYTHON\u7684\u7248\u672c<\/h2>\n<\/p>\n<p><p>\u5728\u5378\u8f7dPython\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u5b9a\u4f60\u7684Mac\u4e0a\u5b89\u88c5\u4e86\u54ea\u4e9b\u7248\u672c\u7684Python\u3002\u8fd9\u4e00\u6b65\u9aa4\u5bf9\u4e8e\u540e\u7eed\u9009\u62e9\u6b63\u786e\u7684\u5378\u8f7d\u547d\u4ee4\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165 <code>python --version<\/code> \u6216 <code>python3 --version<\/code> \u6765\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\u3002<\/li>\n<li>\u5982\u679c\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>ls \/usr\/local\/bin\/python*<\/code> \u547d\u4ee4\u6765\u5217\u51fa\u6240\u6709\u5b89\u88c5\u7684Python\u7248\u672c\u3002<\/li>\n<\/ul>\n<p><h2>\u4e8c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5378\u8f7dPYTHON<\/h2>\n<\/p>\n<p><p>\u4e00\u65e6\u786e\u5b9a\u4e86\u8981\u5378\u8f7d\u7684Python\u7248\u672c\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u6765\u8fdb\u884c\u5220\u9664\u64cd\u4f5c\u4e86\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u5bf9\u4e8e\u901a\u8fc7Homebrew\u5b89\u88c5\u7684Python<\/strong>\uff0c\u53ef\u4ee5\u7b80\u5355\u5730\u8fd0\u884c <code>brew uninstall python<\/code> \u547d\u4ee4\u6765\u5378\u8f7d\u3002<\/li>\n<li>\u5bf9\u4e8e\u624b\u52a8\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>sudo rm -rf<\/code> \u547d\u4ee4\u52a0\u4e0aPython\u7684\u5b89\u88c5\u8def\u5f84\u6765\u5220\u9664\u3002\u4f8b\u5982\uff0c\u5982\u679cPython\u5b89\u88c5\u5728 <code>\/usr\/local\/bin\/python3.7<\/code>\uff0c\u53ef\u4ee5\u8fd0\u884c <code>sudo rm -rf \/usr\/local\/bin\/python3.7<\/code>\u3002<\/li>\n<\/ul>\n<p><h2>\u4e09\u3001\u624b\u52a8\u5220\u9664\u76f8\u5173\u6587\u4ef6<\/h2>\n<\/p>\n<p><p>\u5378\u8f7dPython\u540e\uff0c\u53ef\u80fd\u4f1a\u6709\u4e00\u4e9b\u5173\u8054\u6587\u4ef6\u6b8b\u7559\u5728\u7cfb\u7edf\u4e2d\u3002<\/p>\n<\/p>\n<ul>\n<li>\u5bfc\u822a\u5230 <code>\/Library\/Frameworks\/Python.framework\/Versions\/<\/code> \u76ee\u5f55\uff0c\u5220\u9664\u4e0e\u4f60\u5378\u8f7d\u7684Python\u7248\u672c\u76f8\u5bf9\u5e94\u7684\u6587\u4ef6\u5939\u3002<\/li>\n<li>\u68c0\u67e5 <code>~\/Library\/<\/code> \u76ee\u5f55\u4e0b\u7684 <code>Python<\/code> \u548c <code>Application Support<\/code> \u6587\u4ef6\u5939\uff0c\u5220\u9664\u4efb\u4f55\u4e0ePython\u76f8\u5173\u7684\u6587\u4ef6\u5939\u3002<\/li>\n<\/ul>\n<p><h2>\u56db\u3001\u6e05\u7406\u73af\u5883\u8def\u5f84<\/h2>\n<\/p>\n<p><p>\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u8fd8\u9700\u8981\u4ece\u73af\u5883\u53d8\u91cf\u4e2d\u5220\u9664Python\u7684\u8def\u5f84\uff0c\u4ee5\u786e\u4fdd\u7cfb\u7edf\u4e0d\u4f1a\u5f15\u7528\u5df2\u5378\u8f7d\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<ul>\n<li>\u7f16\u8f91 <code>~\/.bash_profile<\/code> \u6216 <code>~\/.zshrc<\/code> \u6587\u4ef6\uff0c\u67e5\u627e\u4e0e\u5df2\u5378\u8f7dPython\u7248\u672c\u76f8\u5173\u7684\u8def\u5f84\uff0c\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u5220\u9664\u8fd9\u4e9b\u8def\u5f84\u3002<\/li>\n<li>\u6267\u884c <code>source ~\/.bash_profile<\/code> \u6216 <code>source ~\/.zshrc<\/code> \u6765\u66f4\u65b0\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5f7b\u5e95\u4e14\u5b89\u5168\u5730\u4eceMac\u7cfb\u7edf\u4e2d\u5378\u8f7dPython\u3002\u91cd\u8981\u7684\u662f\uff0c\u8fdb\u884c\u8fd9\u4e9b\u64cd\u4f5c\u65f6\u8981\u786e\u4fdd\u6839\u636e\u81ea\u5df1\u7cfb\u7edf\u7684\u5177\u4f53\u60c5\u51b5\u548c\u5b89\u88c5\u65b9\u5f0f\u9009\u62e9\u5408\u9002\u7684\u547d\u4ee4\u548c\u6b65\u9aa4\uff0c\u4ee5\u514d\u5f71\u54cd\u7cfb\u7edf\u4e2d\u5176\u4ed6\u5e94\u7528\u7684\u4f7f\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u600e\u6837\u5728Mac\u4e0a\u5f7b\u5e95\u5378\u8f7dPython\uff1f<\/strong><br \/>\n\u5982\u679c\u60a8\u60f3\u8981\u5f7b\u5e95\u5378\u8f7dPython\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<br \/>\n    1. \u6253\u5f00\u7ec8\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002<br \/>\n    2. \u8f93\u5165\u547d\u4ee4\u201csudo rm -rf \/Library\/Frameworks\/Python.framework\u201d \u5b58\u5728\u6846\u67b6\u5b89\u88c5\u7684\u5730\u65b9\u3002<br \/>\n    3. \u8f93\u5165\u547d\u4ee4\u201csudo rm -rf \/Applications\/Python 3.x\u201d \u5220\u9664Python 3.x\u7684\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u5939\uff08\u6839\u636e\u4f60\u7684\u5b89\u88c5\u7248\u672c\u9009\u62e9\u5bf9\u5e94\u7684\u6587\u4ef6\u5939\uff09\u3002<br \/>\n    4. \u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u547d\u4ee4\u201cnano ~\/.bash_profile\u201d\u6765\u7f16\u8f91bash\u914d\u7f6e\u6587\u4ef6\u3002<br \/>\n    5. \u4f7f\u7528\u952e\u76d8\u4e0a\u7684\u7bad\u5934\u952e\u5c06\u5149\u6807\u79fb\u52a8\u5230\u6587\u4ef6\u7684\u5e95\u90e8\u3002<br \/>\n    6. \u4f7f\u7528Ctrl+K\u7ec4\u5408\u952e\u5220\u9664\u4efb\u4f55\u4e0ePython\u76f8\u5173\u7684\u884c\u3002<br \/>\n    7. \u4f7f\u7528Ctrl+O\u7ec4\u5408\u952e\u4fdd\u5b58\u66f4\u6539\uff0c\u7136\u540e\u6309Enter\u952e\u786e\u8ba4\u6587\u4ef6\u540d\u3002<br \/>\n    8. \u4f7f\u7528Ctrl+X\u7ec4\u5408\u952e\u9000\u51fa\u7f16\u8f91\u5668\u3002<br \/>\n    9. \u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u547d\u4ee4\u201csource ~\/.bash_profile\u201d\u91cd\u65b0\u52a0\u8f7dbash\u914d\u7f6e\u6587\u4ef6\u3002<br \/>\n    10. \u73b0\u5728\uff0cPython\u5df2\u88ab\u5b8c\u5168\u5378\u8f7d\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u5728Mac\u4e0a\u5378\u8f7d\u7279\u5b9a\u7248\u672c\u7684Python\uff1f<\/strong><br \/>\n\u5982\u679c\u60a8\u53ea\u60f3\u5378\u8f7d\u67d0\u4e2a\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<br \/>\n    1. \u6253\u5f00\u7ec8\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002<br \/>\n    2. \u8f93\u5165\u547d\u4ee4\u201cbrew unlink <a href=\"mailto:python@3.x\">python@3.x<\/a>\u201d\uff0c\u5176\u4e2dx\u662f\u4f60\u5e0c\u671b\u5378\u8f7d\u7684Python\u7248\u672c\u53f7\u3002<br \/>\n    3. \u8f93\u5165\u547d\u4ee4\u201cbrew uninstall <a href=\"mailto:python@3.x\">python@3.x<\/a>\u201d\uff0c\u5f7b\u5e95\u5378\u8f7d\u6307\u5b9a\u7248\u672c\u7684Python\u3002<br \/>\n    4. \u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u547d\u4ee4\u201cnano ~\/.bash_profile\u201d\u6765\u7f16\u8f91bash\u914d\u7f6e\u6587\u4ef6\u3002<br \/>\n    5. \u4f7f\u7528\u952e\u76d8\u4e0a\u7684\u7bad\u5934\u952e\u5c06\u5149\u6807\u79fb\u52a8\u5230\u6587\u4ef6\u7684\u5e95\u90e8\u3002<br \/>\n    6. \u4f7f\u7528Ctrl+K\u7ec4\u5408\u952e\u5220\u9664\u4efb\u4f55\u4e0e\u8be5Python\u7248\u672c\u76f8\u5173\u7684\u884c\u3002<br \/>\n    7. \u4f7f\u7528Ctrl+O\u7ec4\u5408\u952e\u4fdd\u5b58\u66f4\u6539\uff0c\u7136\u540e\u6309Enter\u952e\u786e\u8ba4\u6587\u4ef6\u540d\u3002<br \/>\n    8. \u4f7f\u7528Ctrl+X\u7ec4\u5408\u952e\u9000\u51fa\u7f16\u8f91\u5668\u3002<br \/>\n    9. \u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u547d\u4ee4\u201csource ~\/.bash_profile\u201d\u91cd\u65b0\u52a0\u8f7dbash\u914d\u7f6e\u6587\u4ef6\u3002<br \/>\n    10. \u7279\u5b9a\u7248\u672c\u7684Python\u73b0\u5728\u5df2\u88ab\u6210\u529f\u5378\u8f7d\u3002<\/p>\n<p><strong>3. \u662f\u5426\u5efa\u8bae\u5728Mac\u4e0a\u5378\u8f7dPython\uff1f<\/strong><br \/>\n\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0cMac\u9884\u88c5\u7684Python\u5e76\u4e0d\u4f1a\u5e72\u6270\u60a8\u7684\u7cfb\u7edf\u6216\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u7684\u6b63\u5e38\u8fd0\u884c\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u78b0\u5230\u4e0e\u7279\u5b9a\u7248\u672c\u7684Python\u4e0d\u517c\u5bb9\u7684\u95ee\u9898\uff0c\u6216\u8005\u9700\u8981\u901a\u8fc7Homebrew\u6216\u5176\u4ed6\u65b9\u6cd5\u5b89\u88c5\u81ea\u5b9a\u4e49Python\u7248\u672c\uff0c\u8fd9\u65f6\u5378\u8f7d\u6216\u5207\u6362Python\u7248\u672c\u53ef\u80fd\u662f\u4e00\u4e2a\u597d\u7684\u9009\u62e9\u3002\u8bf7\u786e\u4fdd\u5728\u5378\u8f7dPython\u4e4b\u524d\u5907\u4efd\u60a8\u7684\u9879\u76ee\u548c\u76f8\u5173\u6570\u636e\uff0c\u5e76\u8c28\u614e\u8003\u8651\u662f\u5426\u6709\u5fc5\u8981\u5378\u8f7dPython\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5378\u8f7dMac\u4e0a\u7684Python\u901a\u5e38\u6d89\u53ca\u5230\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff0c\u5305\u62ec\u786e\u5b9aPython\u7684\u7248\u672c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u3001\u624b\u52a8\u5220\u9664\u76f8\u5173\u6587\u4ef6\u548c\u6e05 [&hellip;]","protected":false},"author":3,"featured_media":150137,"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\/150132"}],"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=150132"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/150132\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/150137"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=150132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=150132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=150132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}