{"id":1178131,"date":"2025-01-15T18:06:51","date_gmt":"2025-01-15T10:06:51","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1178131.html"},"modified":"2025-01-15T18:06:53","modified_gmt":"2025-01-15T10:06:53","slug":"%e5%a6%82%e4%bd%95%e6%a3%80%e9%aa%8c%e6%9c%89%e6%b2%a1%e6%9c%89%e5%ae%89%e8%a3%85python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1178131.html","title":{"rendered":"\u5982\u4f55\u68c0\u9a8c\u6709\u6ca1\u6709\u5b89\u88c5python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25112855\/74464a54-e8cd-4979-b65e-1e1df8df822d.webp\" alt=\"\u5982\u4f55\u68c0\u9a8c\u6709\u6ca1\u6709\u5b89\u88c5python\" \/><\/p>\n<p><p> \u8981\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u4e86Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a<strong>\u4f7f\u7528\u547d\u4ee4\u884c\u68c0\u67e5\u3001\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u3001\u68c0\u67e5\u64cd\u4f5c\u7cfb\u7edf\u7684\u7a0b\u5e8f\u5217\u8868<\/strong>\u3002\u5176\u4e2d\uff0c\u6700\u7b80\u5355\u4e14\u901a\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u547d\u4ee4\u884c\u68c0\u67e5\u3002\u4f60\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08Windows\uff09\u3001\u7ec8\u7aef\uff08macOS\u3001Linux\uff09\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u547d\u4ee4\u6765\u67e5\u770b\u662f\u5426\u5b89\u88c5\u4e86Python\u3002\u5982\u679c\u5df2\u7ecf\u5b89\u88c5\uff0c\u4f1a\u663e\u793a\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><p><strong>\u8be6\u7ec6\u63cf\u8ff0\u4f7f\u7528\u547d\u4ee4\u884c\u68c0\u67e5\u7684\u65b9\u6cd5<\/strong>\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u6253\u5f00\u547d\u4ee4\u884c\u5de5\u5177<\/strong>\uff1a\u5728Windows\u4e0a\uff0c\u6309\u4e0b<code>Win + R<\/code>\u952e\uff0c\u8f93\u5165<code>cmd<\/code>\u5e76\u6309\u56de\u8f66\u952e\u3002\u5728macOS\u548cLinux\u4e0a\uff0c\u6253\u5f00\u201c\u7ec8\u7aef\u201d\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li><strong>\u8f93\u5165\u547d\u4ee4<\/strong>\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002<\/li>\n<li><strong>\u67e5\u770b\u7ed3\u679c<\/strong>\uff1a\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u5c4f\u5e55\u4e0a\u4f1a\u663e\u793a\u7c7b\u4f3c<code>Python 3.8.5<\/code>\u7684\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u4f1a\u663e\u793a\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u5176\u4ed6\u9519\u8bef\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5982\u4f55\u901a\u8fc7\u5404\u79cd\u65b9\u6cd5\u6765\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u4e86Python\uff0c\u4ee5\u53ca\u5982\u679c\u6ca1\u6709\u5b89\u88c5Python\u8be5\u5982\u4f55\u8fdb\u884c\u5b89\u88c5\u548c\u914d\u7f6e\u3002<\/p>\n<\/p>\n<h2><strong>\u4e00\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u68c0\u67e5<\/strong><\/h2>\n<p><h2>1.1 Windows\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>1.1.1 \u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0b<code>Win + R<\/code>\u952e\u6253\u5f00\u201c\u8fd0\u884c\u201d\u5bf9\u8bdd\u6846\uff0c\u7136\u540e\u8f93\u5165<code>cmd<\/code>\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002\u8fd9\u5c06\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u3002<\/p>\n<\/p>\n<p><h3>1.1.2 \u8f93\u5165\u68c0\u67e5\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4e4b\u4e00\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>1.1.3 \u89e3\u6790\u8f93\u51fa\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u547d\u4ee4\u63d0\u793a\u7b26\u5c06\u663e\u793a\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\u7684\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">Python 3.8.5<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679cPython\u672a\u5b89\u88c5\uff0c\u547d\u4ee4\u63d0\u793a\u7b26\u5c06\u663e\u793a\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u201c&#39;python&#39; \u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4\uff0c\u4e5f\u4e0d\u662f\u53ef\u8fd0\u884c\u7684\u7a0b\u5e8f\u6216\u6279\u5904\u7406\u6587\u4ef6\u201d\u3002<\/p>\n<\/p>\n<p><h2>1.2 macOS\u548cLinux\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>1.2.1 \u6253\u5f00\u7ec8\u7aef<\/h3>\n<\/p>\n<p><p>\u5728macOS\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u201c\u7ec8\u7aef\u201d\u5e94\u7528\u7a0b\u5e8f\u6765\u8bbf\u95ee\u547d\u4ee4\u884c\u754c\u9762\u3002\u4f60\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u83dc\u5355\u4e2d\u627e\u5230\u7ec8\u7aef\uff0c\u6216\u901a\u8fc7\u5feb\u6377\u952e<code>Ctrl + Alt + T<\/code>\uff08\u5728\u67d0\u4e9bLinux\u53d1\u884c\u7248\u4e2d\uff09\u6253\u5f00\u7ec8\u7aef\u3002<\/p>\n<\/p>\n<p><h3>1.2.2 \u8f93\u5165\u68c0\u67e5\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4e4b\u4e00\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>1.2.3 \u89e3\u6790\u8f93\u51fa\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5982\u679cPython\u5df2\u5b89\u88c5\uff0c\u7ec8\u7aef\u5c06\u663e\u793a\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\u7684\u8f93\u51fa\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">Python 3.8.5<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679cPython\u672a\u5b89\u88c5\uff0c\u7ec8\u7aef\u5c06\u663e\u793a\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u5176\u4ed6\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<\/p>\n<h2><strong>\u4e8c\u3001\u68c0\u67e5\u73af\u5883\u53d8\u91cf<\/strong><\/h2>\n<p><h2>2.1 Windows\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>2.1.1 \u6253\u5f00\u7cfb\u7edf\u5c5e\u6027<\/h3>\n<\/p>\n<p><p>\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u56fe\u6807\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002\u5728\u6253\u5f00\u7684\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u94fe\u63a5\u3002<\/p>\n<\/p>\n<p><h3>2.1.2 \u68c0\u67e5\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u540d\u4e3a<code>Path<\/code>\u7684\u53d8\u91cf\uff0c\u53cc\u51fb\u5b83\u3002\u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u68c0\u67e5\u662f\u5426\u5b58\u5728Python\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u5982<code>C:\\Python38<\/code>\u6216<code>C:\\Users\\YourUsername\\AppData\\Local\\Programs\\Python\\Python38<\/code>\u3002<\/p>\n<\/p>\n<p><h3>2.1.3 \u89e3\u6790\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u8def\u5f84\u5b58\u5728\uff0c\u8bf4\u660ePython\u5df2\u5b89\u88c5\u5e76\u914d\u7f6e\u4e86\u73af\u5883\u53d8\u91cf\u3002\u5982\u679c\u8def\u5f84\u4e0d\u5b58\u5728\uff0c\u8bf4\u660ePython\u672a\u5b89\u88c5\u6216\u672a\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h2>2.2 macOS\u548cLinux\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>2.2.1 \u6253\u5f00\u7ec8\u7aef<\/h3>\n<\/p>\n<p><p>\u5728macOS\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u201c\u7ec8\u7aef\u201d\u5e94\u7528\u7a0b\u5e8f\u6765\u8bbf\u95ee\u547d\u4ee4\u884c\u754c\u9762\u3002<\/p>\n<\/p>\n<p><h3>2.2.2 \u8f93\u5165\u68c0\u67e5\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">echo $PATH<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.2.3 \u89e3\u6790\u8f93\u51fa\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u7ec8\u7aef\u5c06\u663e\u793a\u4e00\u7cfb\u5217\u8def\u5f84\uff0c\u4ee5\u5192\u53f7\u5206\u9694\u3002\u68c0\u67e5\u8fd9\u4e9b\u8def\u5f84\u4e2d\u662f\u5426\u5305\u542bPython\u7684\u5b89\u88c5\u8def\u5f84\uff0c\u5982<code>\/usr\/local\/bin<\/code>\u6216<code>\/usr\/bin\/python3<\/code>\u3002\u5982\u679c\u8def\u5f84\u5b58\u5728\uff0c\u8bf4\u660ePython\u5df2\u5b89\u88c5\u5e76\u914d\u7f6e\u4e86\u73af\u5883\u53d8\u91cf\u3002\u5982\u679c\u8def\u5f84\u4e0d\u5b58\u5728\uff0c\u8bf4\u660ePython\u672a\u5b89\u88c5\u6216\u672a\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u4e09\u3001\u68c0\u67e5\u64cd\u4f5c\u7cfb\u7edf\u7684\u7a0b\u5e8f\u5217\u8868<\/strong><\/h2>\n<p><h2>3.1 Windows\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>3.1.1 \u6253\u5f00\u7a0b\u5e8f\u548c\u529f\u80fd<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0b<code>Win + R<\/code>\u952e\u6253\u5f00\u201c\u8fd0\u884c\u201d\u5bf9\u8bdd\u6846\uff0c\u7136\u540e\u8f93\u5165<code>appwiz.cpl<\/code>\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002\u8fd9\u5c06\u6253\u5f00\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\u7a97\u53e3\u3002<\/p>\n<\/p>\n<p><h3>3.1.2 \u67e5\u627ePython<\/h3>\n<\/p>\n<p><p>\u5728\u201c\u7a0b\u5e8f\u548c\u529f\u80fd\u201d\u7a97\u53e3\u4e2d\uff0c\u67e5\u770b\u5df2\u5b89\u88c5\u7a0b\u5e8f\u7684\u5217\u8868\uff0c\u67e5\u627e\u540d\u79f0\u4e2d\u5305\u542b\u201cPython\u201d\u7684\u6761\u76ee\uff0c\u5982\u201cPython 3.8.5\u201d\u3002<\/p>\n<\/p>\n<p><h3>3.1.3 \u89e3\u6790\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u627e\u5230\u5305\u542b\u201cPython\u201d\u7684\u6761\u76ee\uff0c\u8bf4\u660ePython\u5df2\u5b89\u88c5\u3002\u5982\u679c\u672a\u627e\u5230\uff0c\u8bf4\u660ePython\u672a\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h2>3.2 macOS\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>3.2.1 \u6253\u5f00\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u5939<\/h3>\n<\/p>\n<p><p>\u5728macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u201c\u8bbf\u8fbe\u201d\u5e94\u7528\u7a0b\u5e8f\uff0c\u70b9\u51fb\u5de6\u4fa7\u680f\u4e2d\u7684\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\u3002<\/p>\n<\/p>\n<p><h3>3.2.2 \u67e5\u627ePython<\/h3>\n<\/p>\n<p><p>\u5728\u201c\u5e94\u7528\u7a0b\u5e8f\u201d\u6587\u4ef6\u5939\u4e2d\uff0c\u67e5\u627e\u540d\u79f0\u4e2d\u5305\u542b\u201cPython\u201d\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5982\u201cPython 3.8\u201d\u3002<\/p>\n<\/p>\n<p><h3>3.2.3 \u89e3\u6790\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u627e\u5230\u5305\u542b\u201cPython\u201d\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u8bf4\u660ePython\u5df2\u5b89\u88c5\u3002\u5982\u679c\u672a\u627e\u5230\uff0c\u8bf4\u660ePython\u672a\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h2>3.3 Linux\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>3.3.1 \u6253\u5f00\u5305\u7ba1\u7406\u5668<\/h3>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6253\u5f00\u7ec8\u7aef\u5e76\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u68c0\u67e5\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\u3002<\/p>\n<\/p>\n<p><h3>3.3.2 \u4f7f\u7528\u5305\u7ba1\u7406\u5668\u68c0\u67e5Python<\/h3>\n<\/p>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4e4b\u4e00\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">dpkg -l | grep python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">rpm -qa | grep python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3.3.3 \u89e3\u6790\u8f93\u51fa\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u7ec8\u7aef\u5c06\u663e\u793a\u5305\u542b\u201cpython\u201d\u5173\u952e\u5b57\u7684\u5df2\u5b89\u88c5\u8f6f\u4ef6\u5305\u5217\u8868\u3002\u5982\u679c\u5217\u8868\u4e2d\u5305\u542bPython\u7684\u6761\u76ee\uff0c\u8bf4\u660ePython\u5df2\u5b89\u88c5\u3002\u5982\u679c\u5217\u8868\u4e3a\u7a7a\uff0c\u8bf4\u660ePython\u672a\u5b89\u88c5\u3002<\/p>\n<\/p>\n<h2><strong>\u56db\u3001\u5982\u4f55\u5b89\u88c5\u548c\u914d\u7f6ePython<\/strong><\/h2>\n<p><h2>4.1 Windows\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>4.1.1 \u4e0b\u8f7dPython\u5b89\u88c5\u7a0b\u5e8f<\/h3>\n<\/p>\n<p><p>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%9C%A8%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E4%B8%AD%E9%80%89%E6%8B%A9%E9%80%82%E7%94%A8%E4%BA%8EWindows%E7%9A%84Python%E7%89%88%E6%9C%AC%EF%BC%8C%E7%82%B9%E5%87%BB%E4%B8%8B%E8%BD%BD%E6%8C%89%E9%92%AE%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u5728\u4e0b\u8f7d\u9875\u9762\u4e2d\u9009\u62e9\u9002\u7528\u4e8eWindows\u7684Python\u7248\u672c\uff0c\u70b9\u51fb\u4e0b\u8f7d\u6309\u94ae\u3002<\/a><\/p>\n<\/p>\n<p><h3>4.1.2 \u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f<\/h3>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u754c\u9762\u4e2d\uff0c\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u7136\u540e\u70b9\u51fb\u201cInstall Now\u201d\u6309\u94ae\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h3>4.1.3 \u5b8c\u6210\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u547d\u4ee4\uff0c\u9a8c\u8bc1Python\u662f\u5426\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h2>4.2 macOS\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>4.2.1 \u4f7f\u7528Homebrew\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u5728macOS\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Homebrew\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5Python\u3002\u5982\u679c\u5c1a\u672a\u5b89\u88c5Homebrew\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">\/bin\/bash -c &quot;$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/HEAD\/install.sh)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">brew install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4.2.2 \u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u547d\u4ee4\uff0c\u9a8c\u8bc1Python\u662f\u5426\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h2>4.3 Linux\u64cd\u4f5c\u7cfb\u7edf<\/h2>\n<\/p>\n<p><h3>4.3.1 \u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5Python\u3002\u5177\u4f53\u547d\u4ee4\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684Linux\u53d1\u884c\u7248\uff1a<\/p>\n<\/p>\n<p><h4>Debian\/Ubuntu:<\/h4>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo apt update<\/p>\n<p>sudo apt install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>Fedora:<\/h4>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo dnf install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>CentOS\/RHEL:<\/h4>\n<\/p>\n<p><pre><code class=\"language-sh\">sudo yum install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4.3.2 \u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u547d\u4ee4\uff0c\u9a8c\u8bc1Python\u662f\u5426\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<h2><strong>\u4e94\u3001\u914d\u7f6e\u865a\u62df\u73af\u5883<\/strong><\/h2>\n<p><h2>5.1 \u4e3a\u4ec0\u4e48\u9700\u8981\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662fPython\u5f00\u53d1\u4e2d\u4e00\u4e2a\u91cd\u8981\u7684\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u4f60\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u4e3a\u4e0d\u540c\u7684\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u907f\u514d\u4f9d\u8d56\u5305\u51b2\u7a81\u7684\u95ee\u9898\u3002\u8fd9\u5bf9\u4e8e\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u548c\u786e\u4fdd\u9879\u76ee\u7684\u53ef\u79fb\u690d\u6027\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h2>5.2 \u521b\u5efa\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><h3>5.2.1 \u5b89\u88c5virtualenv<\/h3>\n<\/p>\n<p><p>\u5728\u521b\u5efa\u865a\u62df\u73af\u5883\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5<code>virtualenv<\/code>\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>5.2.2 \u521b\u5efa\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">virtualenv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d\uff0c<code>myenv<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u66ff\u6362\u4e3a\u5176\u4ed6\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><h2>5.3 \u6fc0\u6d3b\u548c\u4f7f\u7528\u865a\u62df\u73af\u5883<\/h2>\n<\/p>\n<p><h3>5.3.1 \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\u4f1a\u663e\u793a\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u4ee5\u63d0\u793a\u4f60\u5f53\u524d\u5904\u4e8e\u865a\u62df\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>5.3.2 \u5b89\u88c5\u4f9d\u8d56\u5305<\/h3>\n<\/p>\n<p><p>\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u547d\u4ee4\u6765\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>5.3.3 \u9000\u51fa\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<h2><strong>\u516d\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/strong><\/h2>\n<p><h2>6.1 Python\u547d\u4ee4\u4e0d\u53ef\u7528<\/h2>\n<\/p>\n<p><h3>6.1.1 \u68c0\u67e5\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u786e\u4fddPython\u7684\u5b89\u88c5\u8def\u5f84\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u5982\u679c\u672a\u6dfb\u52a0\uff0c\u8bf7\u624b\u52a8\u5c06Python\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230<code>Path<\/code>\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>6.1.2 \u68c0\u67e5Python\u7248\u672c<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684Python\u547d\u4ee4\u3002\u5bf9\u4e8ePython 3.x\u7248\u672c\uff0c\u5efa\u8bae\u4f7f\u7528<code>python3<\/code>\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><h2>6.2 pip\u547d\u4ee4\u4e0d\u53ef\u7528<\/h2>\n<\/p>\n<p><h3>6.2.1 \u68c0\u67e5pip\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd\u5df2\u5b89\u88c5<code>pip<\/code>\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5<code>pip<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python -m ensurepip --default-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">python3 -m ensurepip --default-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>6.2.2 \u68c0\u67e5\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd<code>pip<\/code>\u7684\u5b89\u88c5\u8def\u5f84\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u5982\u679c\u672a\u6dfb\u52a0\uff0c\u8bf7\u624b\u52a8\u5c06<code>pip<\/code>\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230<code>Path<\/code>\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h2>6.3 \u865a\u62df\u73af\u5883\u65e0\u6cd5\u6fc0\u6d3b<\/h2>\n<\/p>\n<p><h3>6.3.1 \u68c0\u67e5virtualenv\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd\u5df2\u5b89\u88c5<code>virtualenv<\/code>\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-sh\">pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>6.3.2 \u68c0\u67e5\u6fc0\u6d3b\u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684\u6fc0\u6d3b\u547d\u4ee4\u3002Windows\u7cfb\u7edf\u4f7f\u7528<code>myenv\\Scripts\\activate<\/code>\uff0cmacOS\u548cLinux\u7cfb\u7edf\u4f7f\u7528<code>source myenv\/bin\/activate<\/code>\u3002<\/p>\n<\/p>\n<h2><strong>\u4e03\u3001\u603b\u7ed3<\/strong><\/h2>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u4e86Python\uff0c\u5e76\u6839\u636e\u9700\u8981\u8fdb\u884c\u5b89\u88c5\u548c\u914d\u7f6e\u3002<strong>\u4f7f\u7528\u547d\u4ee4\u884c\u68c0\u67e5\u3001\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u3001\u68c0\u67e5\u64cd\u4f5c\u7cfb\u7edf\u7684\u7a0b\u5e8f\u5217\u8868<\/strong>\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u3002\u6b64\u5916\uff0c\u914d\u7f6e\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u51b2\u7a81\u95ee\u9898\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u80fd\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff0c\u8ba9\u4f60\u5728Python\u5f00\u53d1\u4e4b\u8def\u4e0a\u66f4\u52a0\u987a\u5229\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u67e5\u770b\u6211\u7684\u7535\u8111\u4e0a\u662f\u5426\u5df2\u5b89\u88c5Python\uff1f<\/strong><br \/>\u8981\u786e\u8ba4\u662f\u5426\u5b89\u88c5\u4e86Python\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\uff08Windows\u7684\u547d\u4ee4\u63d0\u793a\u7b26\u6216Mac\/Linux\u7684\u7ec8\u7aef\uff09\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u3002\u5982\u679c\u7cfb\u7edf\u5df2\u5b89\u88c5Python\uff0c\u5c06\u663e\u793a\u7248\u672c\u53f7\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u627e\u4e0d\u5230\u8be5\u547d\u4ee4\u3002<\/p>\n<p><strong>\u6211\u5e94\u8be5\u5728\u54ea\u4e2a\u7f51\u7ad9\u4e0b\u8f7dPython\uff1f<\/strong><br \/>Python\u7684\u5b98\u65b9\u4e0b\u8f7d\u5b89\u88c5\u5305\u53ef\u4ee5\u4ece<a href=\"https:\/\/www.python.org\/downloads\/\">Python.org<\/a>\u4e0b\u8f7d\u3002\u8be5\u7f51\u7ad9\u63d0\u4f9b\u4e86\u9002\u5408\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u7684\u6700\u65b0\u7248\u672c\uff0c\u786e\u4fdd\u60a8\u53ef\u4ee5\u4e0b\u8f7d\u5230\u7a33\u5b9a\u4e14\u5b89\u5168\u7684\u5b89\u88c5\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u53d1\u73b0\u6ca1\u6709\u5b89\u88c5Python\uff0c\u5982\u4f55\u8fdb\u884c\u5b89\u88c5\uff1f<\/strong><br \/>\u5728\u786e\u8ba4\u672a\u5b89\u88c5Python\u540e\uff0c\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002\u5b89\u88c5\u8fc7\u7a0b\u901a\u5e38\u5305\u62ec\u8fd0\u884c\u4e0b\u8f7d\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u64cd\u4f5c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5efa\u8bae\u60a8\u5728\u547d\u4ee4\u884c\u4e2d\u518d\u6b21\u68c0\u67e5\uff0c\u4ee5\u786e\u4fdd\u6210\u529f\u5b89\u88c5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u68c0\u9a8c\u662f\u5426\u5b89\u88c5\u4e86Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u68c0\u67e5\u3001\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u3001\u68c0\u67e5\u64cd\u4f5c\u7cfb\u7edf\u7684\u7a0b\u5e8f\u5217\u8868\u3002\u5176\u4e2d [&hellip;]","protected":false},"author":3,"featured_media":1178139,"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\/1178131"}],"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=1178131"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1178131\/revisions"}],"predecessor-version":[{"id":1178140,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1178131\/revisions\/1178140"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1178139"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1178131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1178131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1178131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}