{"id":921909,"date":"2024-12-26T14:22:50","date_gmt":"2024-12-26T06:22:50","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/921909.html"},"modified":"2024-12-26T14:22:52","modified_gmt":"2024-12-26T06:22:52","slug":"python%e5%a6%82%e4%bd%95%e6%9b%b4%e6%96%b0","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/921909.html","title":{"rendered":"python\u5982\u4f55\u66f4\u65b0"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24210646\/3f757ea2-e275-4707-ae53-3d3c2d2db33d.webp\" alt=\"python\u5982\u4f55\u66f4\u65b0\" \/><\/p>\n<p><p> <strong>Python\u66f4\u65b0\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u5305\u62ec\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u3001\u4e0b\u8f7d\u5b89\u88c5\u5305\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7b49\u3002\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u5177\u4f53\u9700\u6c42\u3002\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982Homebrew\u3001apt-get\u6216yum\uff09\u662f\u8bb8\u591a\u7528\u6237\u7684\u9996\u9009\uff0c\u56e0\u4e3a\u5b83\u4eec\u53ef\u4ee5\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u8be6\u7ec6\u63cf\u8ff0\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u66f4\u65b0Python\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u4ee5Homebrew\u4e3a\u4f8b\uff0c\u8fd9\u662fmacOS\u4e0a\u5e38\u7528\u7684\u5305\u7ba1\u7406\u5668\u3002\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8fd0\u884c\u547d\u4ee4<code>brew update<\/code>\u4ee5\u786e\u4fddHomebrew\u81ea\u8eab\u662f\u6700\u65b0\u7684\u3002\u63a5\u4e0b\u6765\uff0c\u8fd0\u884c<code>brew upgrade python<\/code>\u4ee5\u66f4\u65b0Python\u5230\u6700\u65b0\u7248\u672c\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\uff0cHomebrew\u4f1a\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u5e76\u786e\u4fdd\u6240\u6709\u76f8\u5173\u7684\u5305\u4e5f\u5f97\u5230\u66f4\u65b0\u3002\u66f4\u65b0\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python3 --version<\/code>\u547d\u4ee4\u6765\u9a8c\u8bc1Python\u662f\u5426\u5df2\u6210\u529f\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u66f4\u65b0Python<\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u66f4\u65b0Python\u662f\u4e00\u79cd\u7b80\u4fbf\u4e14\u9ad8\u6548\u7684\u65b9\u6cd5\u3002\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u6709\u4e0d\u540c\u7684\u5305\u7ba1\u7406\u5668\uff0c\u5982macOS\u4e0a\u7684Homebrew\uff0cLinux\u4e0a\u7684apt-get\uff08Debian\/Ubuntu\uff09\u6216yum\uff08CentOS\/RHEL\uff09\u3002\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u7b80\u5316\u66f4\u65b0\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<ol>\n<li>Homebrew\uff08macOS\uff09<\/li>\n<\/ol>\n<p><p>Homebrew\u662fmacOS\u4e0a\u975e\u5e38\u6d41\u884c\u7684\u5305\u7ba1\u7406\u5668\u3002\u901a\u8fc7\u5b83\u66f4\u65b0Python\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u786e\u4fddHomebrew\u81ea\u8eab\u662f\u6700\u65b0\u7684\uff0c\u60a8\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u5347\u7ea7Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew upgrade python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6837\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7684Python\u7248\u672c\uff0c\u5e76\u5904\u7406\u6240\u6709\u5fc5\u8981\u7684\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>apt-get\uff08Debian\/Ubuntu\uff09<\/li>\n<\/ol>\n<p><p>\u5728Debian\u6216Ubuntu\u4e0a\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528apt-get\u6765\u66f4\u65b0Python\u3002\u9996\u5148\uff0c\u66f4\u65b0\u5305\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5347\u7ea7Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get upgrade python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5347\u7ea7Python3\u7684\u7248\u672c\uff0c\u540c\u65f6\u4fdd\u6301\u7cfb\u7edf\u7684\u5176\u4ed6\u8f6f\u4ef6\u5305\u5728\u6700\u65b0\u72b6\u6001\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>yum\uff08CentOS\/RHEL\uff09<\/li>\n<\/ol>\n<p><p>\u5bf9\u4e8eCentOS\u6216RHEL\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528yum\u6765\u66f4\u65b0Python\u3002\u9996\u5148\uff0c\u66f4\u65b0yum\u5305\u7d22\u5f15\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum check-update<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo yum install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f1a\u786e\u4fdd\u60a8\u4f7f\u7528\u7684\u662f\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u66f4\u65b0<\/p>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u5e0c\u671b\u76f4\u63a5\u4ecePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u8bbf\u95ee<a href=\"https:\/\/www.python.org\/downloads\/\">Python\u7684\u5b98\u65b9\u4e0b\u8f7d\u9875\u9762<\/a>\u3002\u6839\u636e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u9002\u5408\u7684\u5b89\u88c5\u5305\uff08\u5982Windows\u7684.exe\u6587\u4ef6\u6216macOS\u7684.pkg\u6587\u4ef6\uff09\uff0c\u7136\u540e\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<ol>\n<li>Windows<\/li>\n<\/ol>\n<p><p>\u5728Windows\u4e0a\uff0c\u4e0b\u8f7d\u6700\u65b0\u7684Python\u5b89\u88c5\u7a0b\u5e8f\uff0c\u7136\u540e\u53cc\u51fb\u8fd0\u884c\u3002\u60a8\u5c06\u770b\u5230\u4e00\u4e2a\u5b89\u88c5\u5411\u5bfc\uff0c\u786e\u4fdd\u9009\u4e2d\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\u8f7b\u677e\u4f7f\u7528Python\u3002\u70b9\u51fb\u201cInstall Now\u201d\u6309\u94ae\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>macOS<\/li>\n<\/ol>\n<p><p>\u5728macOS\u4e0a\uff0c\u4e0b\u8f7d.pkg\u6587\u4ef6\u5e76\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u6309\u7167\u5c4f\u5e55\u4e0a\u7684\u8bf4\u660e\u8fdb\u884c\u64cd\u4f5c\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u901a\u8fc7<code>python3<\/code>\u547d\u4ee4\u4f7f\u7528\u65b0\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>Linux<\/li>\n<\/ol>\n<p><p>\u867d\u7136Linux\u7528\u6237\u901a\u5e38\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u6765\u66f4\u65b0Python\uff0c\u4f46\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u4e0b\u8f7d\u6e90\u4ee3\u7801\u5e76\u81ea\u884c\u7f16\u8bd1\u3002\u4e0b\u8f7dtarball\u6587\u4ef6\u540e\uff0c\u89e3\u538b\u7f29\u5e76\u8fdb\u5165\u76ee\u5f55\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/configure<\/p>\n<p>make<\/p>\n<p>sudo make install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u7f16\u8bd1\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528Pyenv\u7ba1\u7406\u591a\u4e2a\u7248\u672c<\/p>\n<\/p>\n<p><p>Pyenv\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5141\u8bb8\u60a8\u5728\u540c\u4e00\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002\u8fd9\u5bf9\u4e8e\u5f00\u53d1\u4eba\u5458\u975e\u5e38\u6709\u7528\uff0c\u5c24\u5176\u662f\u5728\u9700\u8981\u6d4b\u8bd5\u4e0d\u540cPython\u7248\u672c\u4e4b\u95f4\u7684\u517c\u5bb9\u6027\u65f6\u3002<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5Pyenv<\/li>\n<\/ol>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5Pyenv\u3002\u5bf9\u4e8emacOS\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7Homebrew\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">brew install pyenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5bf9\u4e8eLinux\u7528\u6237\uff0c\u53ef\u4ee5\u6309\u7167\u5b98\u65b9\u6587\u6863\u4e2d\u7684\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u5b89\u88c5\u548c\u5207\u6362Python\u7248\u672c<\/li>\n<\/ol>\n<p><p>\u4f7f\u7528Pyenv\u5b89\u88c5\u65b0\u7248\u672c\u7684Python\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u67e5\u770b\u53ef\u7528\u7684Python\u7248\u672c\u5217\u8868\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install --list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u5b89\u88c5\u6240\u9700\u7684\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.x.x  # \u66ff\u6362\u4e3a\u60a8\u9700\u8981\u7684\u7248\u672c\u53f7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e\u5168\u5c40\u6216\u672c\u5730\u9879\u76ee\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv global 3.x.x<\/p>\n<p>pyenv local 3.x.x<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u6216\u7279\u5b9a\u9879\u76ee\u4f7f\u7528\u6307\u5b9a\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56<\/p>\n<\/p>\n<p><p>\u865a\u62df\u73af\u5883\u662fPython\u5f00\u53d1\u4e2d\u7684\u4e00\u9879\u5173\u952e\u6280\u672f\uff0c\u5141\u8bb8\u60a8\u4e3a\u6bcf\u4e2a\u9879\u76ee\u7ef4\u62a4\u72ec\u7acb\u7684\u4f9d\u8d56\u5173\u7cfb\u548cPython\u7248\u672c\u3002\u8fd9\u53ef\u4ee5\u9632\u6b62\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002<\/p>\n<\/p>\n<ol>\n<li>\u521b\u5efa\u865a\u62df\u73af\u5883<\/li>\n<\/ol>\n<p><p>\u4f7f\u7528Python\u81ea\u5e26\u7684venv\u6a21\u5757\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u9996\u5148\uff0c\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv env<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aenv\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/li>\n<\/ol>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u9694\u79bb\u7684\u73af\u5883\u4e2d\u5b89\u88c5\u548c\u7ba1\u7406\u5305\u3002\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u56e0\u64cd\u4f5c\u7cfb\u7edf\u800c\u5f02\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u5728Windows\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\\env\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u5728macOS\u6216Linux\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source env\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u6fc0\u6d3b\u540e\uff0c\u60a8\u5c06\u5728\u7ec8\u7aef\u63d0\u793a\u7b26\u4e2d\u770b\u5230\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56<\/li>\n<\/ol>\n<p><p>\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528pip\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u5305\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210requirements.txt\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5c06\u6765\u53ef\u4ee5\u8f7b\u677e\u91cd\u73b0\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip freeze &gt; requirements.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u5904\u7406\u66f4\u65b0\u540e\u7684\u517c\u5bb9\u6027\u95ee\u9898<\/p>\n<\/p>\n<p><p>\u5728\u66f4\u65b0Python\u540e\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u7279\u522b\u662f\u5728\u9879\u76ee\u4e2d\u4f7f\u7528\u7684\u67d0\u4e9b\u5e93\u53ef\u80fd\u4e0d\u652f\u6301\u65b0\u7248\u672c\u7684Python\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5904\u7406\u517c\u5bb9\u6027\u95ee\u9898\u7684\u5efa\u8bae\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u68c0\u67e5\u5e93\u7684\u652f\u6301\u60c5\u51b5<\/li>\n<\/ol>\n<p><p>\u5728\u66f4\u65b0\u524d\uff0c\u68c0\u67e5\u9879\u76ee\u4e2d\u4f7f\u7528\u7684\u5173\u952e\u5e93\u662f\u5426\u652f\u6301\u65b0\u7248\u672c\u7684Python\u3002\u5927\u591a\u6570\u6d41\u884c\u7684Python\u5e93\u5728\u5176\u6587\u6863\u6216GitHub\u9875\u9762\u4e0a\u90fd\u4f1a\u5217\u51fa\u652f\u6301\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u4f7f\u7528tox\u8fdb\u884c\u591a\u7248\u672c\u6d4b\u8bd5<\/li>\n<\/ol>\n<p><p>Tox\u662f\u4e00\u4e2a\u6d4b\u8bd5\u5de5\u5177\uff0c\u5141\u8bb8\u60a8\u5728\u591a\u4e2aPython\u7248\u672c\u4e0a\u81ea\u52a8\u5316\u6d4b\u8bd5\u3002\u901a\u8fc7\u5728\u9879\u76ee\u4e2d\u6dfb\u52a0tox.ini\u914d\u7f6e\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u4e0d\u540c\u7684Python\u7248\u672c\u548c\u4f9d\u8d56\u73af\u5883\uff0c\u4ee5\u4fbf\u5728\u66f4\u65b0\u540e\u9a8c\u8bc1\u9879\u76ee\u7684\u517c\u5bb9\u6027\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>\u56de\u6eda\u66f4\u65b0<\/li>\n<\/ol>\n<p><p>\u5982\u679c\u53d1\u73b0\u66f4\u65b0\u540e\u5b58\u5728\u65e0\u6cd5\u89e3\u51b3\u7684\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u53ef\u4ee5\u8003\u8651\u56de\u6eda\u5230\u4e4b\u524d\u7684Python\u7248\u672c\u3002\u4f7f\u7528Pyenv\u7ba1\u7406\u591a\u4e2a\u7248\u672c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u603b\u7ed3\u4e0e\u5efa\u8bae<\/p>\n<\/p>\n<p><p>\u5728\u66f4\u65b0Python\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u8fc7\u7a0b\uff0c\u5e76\u786e\u4fdd\u7cfb\u7edf\u6216\u9879\u76ee\u7684\u7a33\u5b9a\u6027\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\u6765\u8bf4\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u662f\u6700\u7b80\u5355\u548c\u6700\u5b89\u5168\u7684\u65b9\u6cd5\uff0c\u800c\u5f00\u53d1\u4eba\u5458\u53ef\u80fd\u9700\u8981\u501f\u52a9Pyenv\u6216\u865a\u62df\u73af\u5883\u6765\u7ba1\u7406\u4e0d\u540c\u7684Python\u7248\u672c\u548c\u9879\u76ee\u4f9d\u8d56\u3002\u901a\u8fc7\u5728\u66f4\u65b0\u524d\u4ed4\u7ec6\u68c0\u67e5\u517c\u5bb9\u6027\u5e76\u5728\u66f4\u65b0\u540e\u8fdb\u884c\u5145\u5206\u7684\u6d4b\u8bd5\uff0c\u60a8\u53ef\u4ee5\u786e\u4fdd\u60a8\u7684\u9879\u76ee\u5728\u6700\u65b0\u7684Python\u7248\u672c\u4e0a\u8fd0\u884c\u826f\u597d\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u6211\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u8981\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u547d\u4ee4<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u3002\u8fd9\u5c06\u663e\u793a\u60a8\u6240\u4f7f\u7528\u7684Python\u7248\u672c\u53f7\u3002\u5982\u679c\u60a8\u7684\u7cfb\u7edf\u4e2d\u540c\u65f6\u5b89\u88c5\u4e86\u591a\u4e2aPython\u7248\u672c\uff0c\u8bf7\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684\u547d\u4ee4\u3002<\/p>\n<p><strong>\u5728Windows\u7cfb\u7edf\u4e0a\u5982\u4f55\u66f4\u65b0Python\uff1f<\/strong><br \/>\u5728Windows\u4e0a\u66f4\u65b0Python\u76f8\u5bf9\u7b80\u5355\u3002\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff0c\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\uff0c\u7136\u540e\u8fd0\u884c\u5b83\u3002\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u63d0\u793a\u60a8\u9009\u62e9\u201c\u66f4\u65b0\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u66ff\u6362\u65e7\u7248\u672c\u3002\u6b64\u5916\uff0c\u786e\u4fdd\u5728\u66f4\u65b0\u8fc7\u7a0b\u4e2d\u9009\u4e2d\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u6b63\u5e38\u4f7f\u7528Python\u3002<\/p>\n<p><strong>\u5728Linux\u7cfb\u7edf\u4e0a\u5982\u4f55\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u66f4\u65b0Python\uff1f<\/strong><br \/>\u5728Linux\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u9002\u5408\u60a8\u53d1\u884c\u7248\u7684\u5305\u7ba1\u7406\u5668\u6765\u66f4\u65b0Python\u3002\u4f8b\u5982\uff0c\u5728Ubuntu\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>sudo apt update<\/code>\u548c<code>sudo apt upgrade python3<\/code>\u3002\u5bf9\u4e8e\u5176\u4ed6\u53d1\u884c\u7248\uff0c\u6bd4\u5982Fedora\uff0c\u53ef\u4ee5\u4f7f\u7528<code>sudo dnf upgrade python3<\/code>\u3002\u786e\u4fdd\u5728\u66f4\u65b0\u4e4b\u524d\u5907\u4efd\u91cd\u8981\u7684\u4ee3\u7801\u548c\u9879\u76ee\uff0c\u4ee5\u9632\u51fa\u73b0\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u66f4\u65b0\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u5305\u62ec\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u3001\u4e0b\u8f7d\u5b89\u88c5\u5305\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7b49\u3002\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u60a8\u7684\u64cd [&hellip;]","protected":false},"author":3,"featured_media":921915,"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\/921909"}],"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=921909"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/921909\/revisions"}],"predecessor-version":[{"id":921917,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/921909\/revisions\/921917"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/921915"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=921909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=921909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=921909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}