{"id":1096528,"date":"2025-01-08T15:02:13","date_gmt":"2025-01-08T07:02:13","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1096528.html"},"modified":"2025-01-08T15:02:15","modified_gmt":"2025-01-08T07:02:15","slug":"%e5%a6%82%e4%bd%95%e8%ae%a9%e7%94%b5%e8%84%91%e9%bb%98%e8%ae%a4%e8%b0%83%e7%94%a8python3-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1096528.html","title":{"rendered":"\u5982\u4f55\u8ba9\u7535\u8111\u9ed8\u8ba4\u8c03\u7528python3"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24211711\/4d04f670-540f-454f-b542-6e74a9c95cef.webp\" alt=\"\u5982\u4f55\u8ba9\u7535\u8111\u9ed8\u8ba4\u8c03\u7528python3\" \/><\/p>\n<p><p> \u8981\u8ba9\u7535\u8111\u9ed8\u8ba4\u8c03\u7528Python3\uff0c\u4f60\u9700\u8981\u8bbe\u7f6e\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u3001\u4fee\u6539\u7cfb\u7edf\u8def\u5f84\u4ee5\u53ca\u4f7f\u7528\u522b\u540d\u7b49\u65b9\u6cd5\u3002<strong>\u4fee\u6539\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3001\u8bbe\u7f6e\u7cfb\u7edf\u8def\u5f84\u3001\u4f7f\u7528\u522b\u540d<\/strong>\u90fd\u662f\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u7684\u6709\u6548\u65b9\u6cd5\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\uff1a<strong>\u4fee\u6539\u7cfb\u7edf\u8def\u5f84<\/strong>\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4fee\u6539\u7cfb\u7edf\u73af\u5883\u53d8\u91cf<\/h2>\n<\/p>\n<p><h3>1.1 Windows\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u8bbe\u7f6e\u9ed8\u8ba4Python\u7248\u672c\u7684\u65b9\u6cd5\u5305\u62ec\u4fee\u6539\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\uff0c\u70b9\u51fb\u201c\u7cfb\u7edf\u548c\u5b89\u5168\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u7cfb\u7edf\u201d\u3002<\/li>\n<li>\u5728\u5de6\u4fa7\u83dc\u5355\u4e2d\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u5f39\u51fa\u7684\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\u627e\u5230\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u5e76\u9009\u62e9\u201cPath\u201d\u53d8\u91cf\uff0c\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u6dfb\u52a0Python3\u7684\u5b89\u88c5\u8def\u5f84\uff08\u4f8b\u5982<code>C:\\Python39<\/code>\uff09\u3002<\/li>\n<li>\u786e\u4fddPython3\u7684\u8def\u5f84\u5728Python2\u8def\u5f84\u7684\u524d\u9762\uff0c\u8fd9\u6837\u7cfb\u7edf\u4f1a\u9996\u5148\u67e5\u627ePython3\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\uff0c\u4fdd\u5b58\u66f4\u6539\u5e76\u5173\u95ed\u6240\u6709\u7a97\u53e3\u3002<\/li>\n<\/ol>\n<p><h3>1.2 macOS\u548cLinux\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982<code>nano<\/code>\u6216<code>vim<\/code>\uff09\u6253\u5f00<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">nano ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff0c\u4ee5\u8bbe\u7f6ePython3\u4e3a\u9ed8\u8ba4\u7248\u672c\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">alias python=python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<\/li>\n<li>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u65f6\u9ed8\u8ba4\u8c03\u7528Python3\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u8bbe\u7f6e\u7cfb\u7edf\u8def\u5f84<\/h2>\n<\/p>\n<p><h3>2.1 Windows\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u7cfb\u7edf\u8def\u5f84\u6765\u9ed8\u8ba4\u8c03\u7528Python3\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d\uff0c\u70b9\u51fb\u201c\u7cfb\u7edf\u548c\u5b89\u5168\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u7cfb\u7edf\u201d\u3002<\/li>\n<li>\u5728\u5de6\u4fa7\u83dc\u5355\u4e2d\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u5f39\u51fa\u7684\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\u627e\u5230\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u5e76\u9009\u62e9\u201cPath\u201d\u53d8\u91cf\uff0c\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u6dfb\u52a0Python3\u7684\u5b89\u88c5\u8def\u5f84\uff08\u4f8b\u5982<code>C:\\Python39<\/code>\uff09\u3002<\/li>\n<li>\u786e\u4fddPython3\u7684\u8def\u5f84\u5728Python2\u8def\u5f84\u7684\u524d\u9762\uff0c\u8fd9\u6837\u7cfb\u7edf\u4f1a\u9996\u5148\u67e5\u627ePython3\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\uff0c\u4fdd\u5b58\u66f4\u6539\u5e76\u5173\u95ed\u6240\u6709\u7a97\u53e3\u3002<\/li>\n<\/ol>\n<p><h3>2.2 macOS\u548cLinux\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982<code>nano<\/code>\u6216<code>vim<\/code>\uff09\u6253\u5f00<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">nano ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff0c\u4ee5\u8bbe\u7f6ePython3\u4e3a\u9ed8\u8ba4\u7248\u672c\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">export PATH=&quot;\/usr\/local\/bin\/python3:$PATH&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<\/li>\n<li>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u65f6\u9ed8\u8ba4\u8c03\u7528Python3\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u522b\u540d<\/h2>\n<\/p>\n<p><h3>3.1 Windows\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u522b\u540d\u6765\u9ed8\u8ba4\u8c03\u7528Python3\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u201c\u547d\u4ee4\u63d0\u793a\u7b26\u201d\u3002<\/li>\n<li>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u521b\u5efa\u4e00\u4e2a\u522b\u540d\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">doskey python=python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3.2 macOS\u548cLinux\u7cfb\u7edf<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982<code>nano<\/code>\u6216<code>vim<\/code>\uff09\u6253\u5f00<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">nano ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff0c\u4ee5\u8bbe\u7f6ePython3\u4e3a\u9ed8\u8ba4\u7248\u672c\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">alias python=python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<\/li>\n<li>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u65f6\u9ed8\u8ba4\u8c03\u7528Python3\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u4f7f\u7528pyenv\u7ba1\u7406Python\u7248\u672c<\/h2>\n<\/p>\n<p><h3>4.1 \u5b89\u88c5pyenv<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>pyenv<\/code>\u6765\u7ba1\u7406Python\u7248\u672c\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u5b89\u88c5\u4f9d\u8d56\u9879\uff08\u4ee5Ubuntu\u4e3a\u4f8b\uff09\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">sudo apt-get update<\/p>\n<p>sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \\<\/p>\n<p>libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \\<\/p>\n<p>libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev \\<\/p>\n<p>liblzma-dev python-openssl git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u5b89\u88c5<code>pyenv<\/code>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">curl https:\/\/pyenv.run | bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li>\u6dfb\u52a0\u4ee5\u4e0b\u884c\u5230<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u4e2d\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">export PATH=&quot;$HOME\/.pyenv\/bin:$PATH&quot;<\/p>\n<p>eval &quot;$(pyenv init --path)&quot;<\/p>\n<p>eval &quot;$(pyenv init -)&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"5\">\n<li>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4.2 \u4f7f\u7528pyenv\u8bbe\u7f6ePython3\u4e3a\u9ed8\u8ba4\u7248\u672c<\/h3>\n<\/p>\n<ol>\n<li>\u5b89\u88c5\u6240\u9700\u7684Python3\u7248\u672c\uff08\u4f8b\u59823.9.0\uff09\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">pyenv install 3.9.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u8bbe\u7f6e\u5168\u5c40\u9ed8\u8ba4Python\u7248\u672c\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">pyenv global 3.9.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u65f6\u9ed8\u8ba4\u8c03\u7528Python3\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u4f7f\u7528Anaconda\u7ba1\u7406Python\u7248\u672c<\/h2>\n<\/p>\n<p><h3>5.1 \u5b89\u88c5Anaconda<\/h3>\n<\/p>\n<p><p>\u5728macOS\u3001Linux\u548cWindows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Anaconda\u6765\u7ba1\u7406Python\u7248\u672c\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u4e0b\u8f7dAnaconda\u5b89\u88c5\u5305\uff1a<a href=\"https:\/\/www.anaconda.com\/products\/individual\">https:\/\/www.anaconda.com\/products\/individual<\/a><\/li>\n<li>\u8fd0\u884c\u5b89\u88c5\u5305\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<\/ol>\n<p><h3>5.2 \u521b\u5efaPython3\u73af\u5883<\/h3>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u6216Anaconda Prompt\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python3\u73af\u5883\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">conda create -n mypython3 python=3.9<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u6fc0\u6d3b\u65b0\u73af\u5883\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">conda activate mypython3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>5.3 \u8bbe\u7f6e\u9ed8\u8ba4\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982<code>nano<\/code>\u6216<code>vim<\/code>\uff09\u6253\u5f00<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">nano ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff0c\u4ee5\u6fc0\u6d3b\u9ed8\u8ba4\u73af\u5883\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">source ~\/anaconda3\/bin\/activate mypython3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<\/li>\n<li>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u65f6\u9ed8\u8ba4\u8c03\u7528Python3\u3002<\/p>\n<\/p>\n<p><h2>\u516d\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u8981\u8ba9\u7535\u8111\u9ed8\u8ba4\u8c03\u7528Python3\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7<strong>\u4fee\u6539\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3001\u8bbe\u7f6e\u7cfb\u7edf\u8def\u5f84\u3001\u4f7f\u7528\u522b\u540d\u3001\u4f7f\u7528pyenv\u7ba1\u7406Python\u7248\u672c\u3001\u4f7f\u7528Anaconda\u7ba1\u7406Python\u7248\u672c<\/strong>\u7b49\u65b9\u6cd5\u6765\u5b9e\u73b0\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u70b9\u548c\u9002\u7528\u573a\u666f\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002\u901a\u8fc7\u4e0a\u8ff0\u8be6\u7ec6\u6b65\u9aa4\u7684\u4ecb\u7ecd\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u4f60\u987a\u5229\u5730\u8bbe\u7f6e\u7535\u8111\u9ed8\u8ba4\u8c03\u7528Python3\uff0c\u4ece\u800c\u63d0\u9ad8\u5de5\u4f5c\u548c\u5b66\u4e60\u7684\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u5f53\u524d\u7535\u8111\u4e0a\u5b89\u88c5\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u8981\u67e5\u770b\u60a8\u7535\u8111\u4e0a\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u3002\u8fd9\u5c06\u663e\u793a\u51fa\u5f53\u524d\u9ed8\u8ba4\u8c03\u7528\u7684Python\u7248\u672c\u3002\u5982\u679c\u8f93\u51fa\u7684\u662fPython 2.x\u7248\u672c\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u66f4\u6539\u9ed8\u8ba4\u8bbe\u7f6e\u3002<\/p>\n<p><strong>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u5c06Python 3\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u7248\u672c\uff1f<\/strong><br \/>\u5728Windows\u4e0a\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u73af\u5883\u53d8\u91cf\u6765\u8bbe\u5b9a\u9ed8\u8ba4\u7684Python\u7248\u672c\u3002\u6253\u5f00\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\uff0c\u8fdb\u5165\u201c\u73af\u5883\u53d8\u91cf\u201d\u8bbe\u7f6e\uff0c\u627e\u5230\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e2d\u7684\u201cPath\u201d\u53d8\u91cf\uff0c\u786e\u4fddPython 3\u7684\u5b89\u88c5\u8def\u5f84\u5728\u5217\u8868\u7684\u524d\u9762\u3002\u91cd\u542f\u547d\u4ee4\u63d0\u793a\u7b26\u540e\uff0c\u8f93\u5165<code>python<\/code>\u547d\u4ee4\uff0c\u68c0\u67e5\u662f\u5426\u5df2\u9ed8\u8ba4\u8c03\u7528Python 3\u3002<\/p>\n<p><strong>\u5728macOS\u6216Linux\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u66f4\u6539\u9ed8\u8ba4\u7684Python\u7248\u672c\uff1f<\/strong><br \/>\u5728macOS\u6216Linux\u4e0a\uff0c\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u7b26\u53f7\u94fe\u63a5\u6765\u66f4\u6539\u9ed8\u8ba4\u7248\u672c\u3002\u4f7f\u7528\u547d\u4ee4<code>sudo ln -sf \/usr\/bin\/python3 \/usr\/bin\/python<\/code>\uff0c\u8fd9\u5c06\u628a<code>python<\/code>\u547d\u4ee4\u6307\u5411<code>python3<\/code>\u3002\u786e\u4fdd\u60a8\u62e5\u6709\u7ba1\u7406\u5458\u6743\u9650\uff0c\u5e76\u5728\u6267\u884c\u547d\u4ee4\u540e\u68c0\u67e5\u66f4\u6539\u662f\u5426\u751f\u6548\u3002<\/p>\n<p><strong>\u5728\u4f7f\u7528\u865a\u62df\u73af\u5883\u65f6\uff0c\u5982\u4f55\u786e\u4fdd\u8c03\u7528\u7684\u662fPython 3\uff1f<\/strong><br \/>\u5728\u521b\u5efa\u865a\u62df\u73af\u5883\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u4f7f\u7528Python 3\u7248\u672c\u3002\u4f7f\u7528\u547d\u4ee4<code>python3 -m venv myenv<\/code>\u521b\u5efa\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u5728\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f7f\u7528<code>python<\/code>\u547d\u4ee4\u65f6\u4f1a\u8c03\u7528Python 3\u3002\u8fdb\u5165\u865a\u62df\u73af\u5883\u540e\uff0c\u8f93\u5165<code>python --version<\/code>\u4ee5\u786e\u8ba4\u5f53\u524d\u4f7f\u7528\u7684Python\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u8ba9\u7535\u8111\u9ed8\u8ba4\u8c03\u7528Python3\uff0c\u4f60\u9700\u8981\u8bbe\u7f6e\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u3001\u4fee\u6539\u7cfb\u7edf\u8def\u5f84\u4ee5\u53ca\u4f7f\u7528\u522b\u540d\u7b49\u65b9\u6cd5\u3002\u4fee\u6539\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3001\u8bbe [&hellip;]","protected":false},"author":3,"featured_media":1096538,"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\/1096528"}],"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=1096528"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1096528\/revisions"}],"predecessor-version":[{"id":1096539,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1096528\/revisions\/1096539"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1096538"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1096528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1096528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1096528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}