{"id":350,"date":"2025-01-12T07:45:28","date_gmt":"2025-01-11T23:45:28","guid":{"rendered":"http:\/\/sqtcw.cn\/?p=350"},"modified":"2025-01-12T07:45:28","modified_gmt":"2025-01-11T23:45:28","slug":"%e6%80%8e%e6%a0%b7%e5%9c%a8%e5%ae%89%e8%a3%85python%e6%97%b6%e9%85%8d%e7%bd%ae%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/www.cnitw.com\/?p=350","title":{"rendered":"\u600e\u6837\u5728\u5b89\u88c5Python\u65f6\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1f"},"content":{"rendered":"\n<p>\u4ee5\u4e0b\u662f\u5728\u5b89\u88c5 Python \u65f6\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p>**Windows \u7cfb\u7edf\uff1a**<\/p>\n\n\n\n<p>1. \u5b89\u88c5 Python\uff1a\u6b63\u5e38\u5b89\u88c5 Python\uff0c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u4f1a\u81ea\u52a8\u5c06 Python \u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u5982\u679c\u5b89\u88c5\u65f6\u6ca1\u6709\u9009\u62e9\u8fd9\u4e2a\u9009\u9879\uff0c\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>2. \u627e\u5230 Python \u5b89\u88c5\u8def\u5f84\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u786e\u5b9a Python \u7684\u5b89\u88c5\u8def\u5f84\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u5b89\u88c5\u8def\u5f84\u4e3a `C:\\PythonXX`\uff08\u5176\u4e2d `XX` \u662f Python \u7684\u7248\u672c\u53f7\uff09\u3002<\/p>\n\n\n\n<p>3. \u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u540d\u4e3a\u201cPath\u201d\u7684\u53d8\u91cf\u5e76\u53cc\u51fb\u5b83\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u8f93\u5165 Python \u7684\u5b89\u88c5\u8def\u5f84\uff0c\u4f8b\u5982 `C:\\PythonXX` \u548c `C:\\PythonXX\\Scripts`\uff08\u8fd9\u4e00\u6b65\u662f\u4e3a\u4e86\u80fd\u591f\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8fd0\u884c Python \u548c\u4f7f\u7528 pip \u7b49\u5de5\u5177\uff09\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u8bbe\u7f6e\u3002<\/p>\n\n\n\n<p>4. \u9a8c\u8bc1\u914d\u7f6e\uff1a\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165 `python &#8211;version`\uff0c\u5982\u679c\u663e\u793a Python \u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8bf4\u660e\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6210\u529f\u3002<\/p>\n\n\n\n<p>**macOS \u7cfb\u7edf\uff1a**<\/p>\n\n\n\n<p>1. \u5b89\u88c5 Python\uff1a\u53ef\u4ee5\u4ece Python \u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\uff0c\u6216\u8005\u4f7f\u7528 Homebrew \u7b49\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u3002<\/p>\n\n\n\n<p>2. \u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff08\u4f7f\u7528 `.bash_profile` \u6216 `.zshrc` \u6587\u4ef6\uff09\uff1a<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u6253\u5f00\u7ec8\u7aef\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00 `.bash_profile` \u6587\u4ef6\uff08\u5982\u679c\u4f7f\u7528 Zsh &nbsp;shell\uff0c\u5219\u6253\u5f00 `.zshrc` \u6587\u4ef6\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a`nano ~\/.bash_profile` \u6216 `nano ~\/.zshrc`\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a`export PATH=&#8221;\/Library\/Frameworks\/Python.framework\/Versions\/XX\/bin:$PATH&#8221;`\uff08\u5c06 `XX` \u66ff\u6362\u4e3a\u4f60\u5b89\u88c5\u7684 Python \u7248\u672c\u53f7\uff09\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u6587\u672c\u7f16\u8f91\u5668\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 `source ~\/.bash_profile` \u6216 `source ~\/.zshrc`\u3002<\/p>\n\n\n\n<p>3. \u9a8c\u8bc1\u914d\u7f6e\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 `python &#8211;version`\uff0c\u5982\u679c\u663e\u793a Python \u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8bf4\u660e\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6210\u529f\u3002<\/p>\n\n\n\n<p>**Linux \u7cfb\u7edf\uff08\u4ee5 Ubuntu \u4e3a\u4f8b\uff09\uff1a**<\/p>\n\n\n\n<p>1. \u5b89\u88c5 Python\uff1a\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982 apt\uff09\u5b89\u88c5 Python\u3002<\/p>\n\n\n\n<p>2. \u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u6253\u5f00\u7ec8\u7aef\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00 `~\/.bashrc` \u6587\u4ef6\uff0c\u4f8b\u5982 `nano ~\/.bashrc`\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a`export PATH=&#8221;\/usr\/bin\/pythonXX:$PATH&#8221;`\uff08\u5c06 `XX` \u66ff\u6362\u4e3a\u4f60\u5b89\u88c5\u7684 Python \u7248\u672c\u53f7\uff0c\u5982\u679c Python \u5b89\u88c5\u5728\u5176\u4ed6\u8def\u5f84\uff0c\u9700\u8981\u76f8\u5e94\u5730\u8c03\u6574\uff09\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u6587\u672c\u7f16\u8f91\u5668\u3002<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&#8211; \u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 `source ~\/.bashrc`\u3002<\/p>\n\n\n\n<p>3. \u9a8c\u8bc1\u914d\u7f6e\uff1a\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 `python &#8211;version`\uff0c\u5982\u679c\u663e\u793a Python \u7684\u7248\u672c\u4fe1\u606f\uff0c\u5219\u8bf4\u660e\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6210\u529f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u662f\u5728\u5b89\u88c5 Python \u65f6\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u7684\u6b65\u9aa4\uff1a **Windows \u7cfb\u7edf\uff1a** 1. \u5b89\u88c5 Python\uff1a\u6b63\u5e38\u5b89\u88c5 Python\uff0c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u9009\u62e9\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u4f1a\u81ea\u52a8\u5c06 Python \u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u5982\u679c\u5b89\u88c5\u65f6\u6ca1\u6709\u9009\u62e9\u8fd9\u4e2a\u9009\u9879\uff0c\u53ef\u4ee5\u624b\u52a8\u914d\u7f6e\u3002 2. \u627e\u5230 Python \u5b89\u88c5\u8def\u5f84\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u786e\u5b9a Python \u7684\u5b89\u88c5\u8def\u5f84\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u9ed8\u8ba4\u5b89\u88c5\u8def\u5f84\u4e3a `C:\\PythonXX`\uff08\u5176\u4e2d `XX` \u662f Python \u7684\u7248\u672c\u53f7\uff09\u3002 3. \u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a &nbsp;&nbsp;&nbsp;&#8211; \u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002 &nbsp;&nbsp;&nbsp;&#8211;&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,15],"tags":[],"class_list":["post-350","post","type-post","status-publish","format-standard","hentry","category-python","category-15"],"_links":{"self":[{"href":"http:\/\/www.cnitw.com\/index.php?rest_route=\/wp\/v2\/posts\/350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.cnitw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.cnitw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.cnitw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.cnitw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=350"}],"version-history":[{"count":0,"href":"http:\/\/www.cnitw.com\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.cnitw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.cnitw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.cnitw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}