{"id":1082252,"date":"2025-01-08T12:47:07","date_gmt":"2025-01-08T04:47:07","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1082252.html"},"modified":"2025-01-08T12:47:09","modified_gmt":"2025-01-08T04:47:09","slug":"%e6%a0%91%e8%8e%93%e6%b4%be%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85python3-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1082252.html","title":{"rendered":"\u6811\u8393\u6d3e\u4e2d\u5982\u4f55\u5b89\u88c5python3"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24183901\/8c3ebe21-be10-435a-bc79-1f50cba44a17.webp\" alt=\"\u6811\u8393\u6d3e\u4e2d\u5982\u4f55\u5b89\u88c5python3\" \/><\/p>\n<p><p> <strong>\u6811\u8393\u6d3e\u4e2d\u5b89\u88c5Python3\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u68c0\u67e5\u5f53\u524d\u7248\u672c\u3001\u66f4\u65b0\u8f6f\u4ef6\u5305\u3001\u5b89\u88c5Python3\u3001\u9a8c\u8bc1\u5b89\u88c5\u3002<\/strong> \u5176\u4e2d\uff0c<strong>\u66f4\u65b0\u8f6f\u4ef6\u5305<\/strong>\u662f\u786e\u4fdd\u4f60\u80fd\u591f\u83b7\u53d6\u5230\u6700\u65b0\u7248\u672c\u7684Python3\uff0c\u5e76\u907f\u514d\u4e0e\u7cfb\u7edf\u4e2d\u7684\u5176\u4ed6\u8f6f\u4ef6\u5305\u51b2\u7a81\u3002\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u68c0\u67e5\u5f53\u524dPython\u7248\u672c<\/p>\n<p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u77e5\u9053\u6811\u8393\u6d3e\u4e0a\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u4ee5\u53ca\u5176\u7248\u672c\u4fe1\u606f\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5\u4e86Python3\uff0c\u7ec8\u7aef\u4f1a\u663e\u793a\u5f53\u524d\u7684\u7248\u672c\u53f7\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u6216\u8005\u7248\u672c\u4e0d\u662f\u4f60\u9700\u8981\u7684\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u7684\u6b65\u9aa4\u4f1a\u5e2e\u52a9\u4f60\u5b89\u88c5\u6216\u66f4\u65b0Python3\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u66f4\u65b0\u8f6f\u4ef6\u5305<\/p>\n<p>\u5728\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5\u4efb\u4f55\u8f6f\u4ef6\u4e4b\u524d\uff0c\u6700\u597d\u5148\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\u5e76\u5347\u7ea7\u73b0\u6709\u7684\u8f6f\u4ef6\u5305\uff0c\u4ee5\u786e\u4fdd\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b8c\u6210\u6b64\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo apt-get update<\/p>\n<p>sudo apt-get upgrade<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e24\u4e2a\u547d\u4ee4\u5206\u522b\u7528\u4e8e\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\u548c\u5347\u7ea7\u7cfb\u7edf\u4e2d\u73b0\u6709\u7684\u8f6f\u4ef6\u5305\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u5b89\u88c5Python3<\/p>\n<p>\u5728\u66f4\u65b0\u5b8c\u8f6f\u4ef6\u5305\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5b89\u88c5Python3\u4e86\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo apt-get install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528<code>python3 --version<\/code>\u547d\u4ee4\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5b89\u88c5pip3<\/p>\n<p>pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b89\u88c5pip3\u53ef\u4ee5\u8ba9\u4f60\u65b9\u4fbf\u5730\u5b89\u88c5\u548c\u7ba1\u7406Python3\u7684\u7b2c\u4e09\u65b9\u5e93\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5pip3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo apt-get install python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>pip3 --version<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u8bbe\u7f6ePython3\u4e3a\u9ed8\u8ba4\u7248\u672c\uff08\u53ef\u9009\uff09<\/p>\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u65f6\uff0c\u9ed8\u8ba4\u4f7f\u7528\u7684\u662fPython3\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u522b\u540d\u6765\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u7f16\u8f91\u4f60\u7684bash\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">nano ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">alias python=python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">source ~\/.bashrc<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165<code>python --version<\/code>\u6765\u786e\u8ba4\u662f\u5426\u5df2\u5c06Python3\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u5b89\u88c5\u865a\u62df\u73af\u5883\uff08\u53ef\u9009\uff09<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u9694\u79bb\u9879\u76ee\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5<code>virtualenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo pip3 install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u548c\u6fc0\u6d3b\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">virtualenv myenv<\/p>\n<p>source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5\u6240\u9700\u7684\u5e93\uff0c\u5e76\u786e\u4fdd\u5b83\u4eec\u4e0d\u4f1a\u5f71\u54cd\u5230\u7cfb\u7edf\u7684\u5176\u4ed6\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><p>\u4e03\u3001\u5b89\u88c5\u5e38\u7528Python\u5e93<\/p>\n<p>\u5b89\u88c5\u5b8cPython3\u548cpip3\u540e\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u5e38\u7528\u7684Python\u5e93\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u5e93\u7684\u5b89\u88c5\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">pip3 install numpy<\/p>\n<p>pip3 install pandas<\/p>\n<p>pip3 install matplotlib<\/p>\n<p>pip3 install scipy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u5e93\u6db5\u76d6\u4e86\u6570\u636e\u5904\u7406\u3001\u79d1\u5b66\u8ba1\u7b97\u3001\u6570\u636e\u53ef\u89c6\u5316\u7b49\u591a\u4e2a\u65b9\u9762\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u5f00\u5c55Python\u5f00\u53d1\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<p><p>\u516b\u3001\u4f7f\u7528IDLE\u8fdb\u884c\u5f00\u53d1<\/p>\n<p>\u6811\u8393\u6d3e\u81ea\u5e26\u4e86\u4e00\u4e2aPython\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDLE\uff09\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u7f16\u5199\u548c\u8c03\u8bd5Python\u4ee3\u7801\u3002\u6253\u5f00IDLE\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">idle3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>IDLE\u63d0\u4f9b\u4e86\u4e00\u4e2a\u53cb\u597d\u7684\u7528\u6237\u754c\u9762\uff0c\u4fbf\u4e8e\u4f60\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801\u3002\u5982\u679c\u4f60\u4e0d\u559c\u6b22IDLE\uff0c\u8fd8\u53ef\u4ee5\u5b89\u88c5\u5176\u4ed6\u7684IDE\uff0c\u5982Thonny\u3001PyCharm\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u4e5d\u3001\u89e3\u51b3\u5e38\u89c1\u95ee\u9898<\/p>\n<p>\u5728\u5b89\u88c5\u548c\u4f7f\u7528Python3\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f9d\u8d56\u51b2\u7a81<\/strong>\uff1a\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u4f9d\u8d56\u51b2\u7a81\uff0c\u5c1d\u8bd5\u4f7f\u7528<code>sudo apt-get -f install<\/code>\u547d\u4ee4\u6765\u4fee\u590d\u4f9d\u8d56\u5173\u7cfb\u3002<\/li>\n<li><strong>\u7f51\u7edc\u95ee\u9898<\/strong>\uff1a\u5982\u679c\u7f51\u7edc\u8fde\u63a5\u4e0d\u7a33\u5b9a\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6362\u7f51\u7edc\u6e90\uff0c\u4ee5\u52a0\u5feb\u8f6f\u4ef6\u5305\u7684\u4e0b\u8f7d\u901f\u5ea6\u3002<\/li>\n<li><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\u5982\u679c\u9047\u5230\u6743\u9650\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u5728\u547d\u4ee4\u524d\u52a0\u4e0a<code>sudo<\/code>\uff0c\u4ee5\u83b7\u53d6\u7ba1\u7406\u5458\u6743\u9650\u3002<\/li>\n<\/ol>\n<p><p>\u5341\u3001\u4fdd\u6301Python3\u6700\u65b0<\/p>\n<p>Python3\u5728\u4e0d\u65ad\u66f4\u65b0\uff0c\u5b9a\u671f\u68c0\u67e5\u5e76\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u53ef\u4ee5\u4eab\u53d7\u66f4\u591a\u7684\u529f\u80fd\u548c\u66f4\u9ad8\u7684\u5b89\u5168\u6027\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0Python3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">sudo apt-get update<\/p>\n<p>sudo apt-get upgrade python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5728\u6811\u8393\u6d3e\u4e0a\u6210\u529f\u5b89\u88c5\u5e76\u914d\u7f6ePython3\uff0c\u5f00\u59cb\u4f60\u7684Python\u5f00\u53d1\u4e4b\u65c5\u3002\u65e0\u8bba\u662f\u5b66\u4e60\u7f16\u7a0b\u3001\u5f00\u53d1\u9879\u76ee\uff0c\u8fd8\u662f\u8fdb\u884c\u6570\u636e\u5206\u6790\uff0cPython3\u90fd\u5c06\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Python3\u9700\u8981\u54ea\u4e9b\u6b65\u9aa4\uff1f<\/strong><br \/>\u5728\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5Python3\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u6811\u8393\u6d3e\u5df2\u7ecf\u8fde\u63a5\u5230\u4e92\u8054\u7f51\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff1a<code>sudo apt update<\/code>\u3002\u63a5\u7740\uff0c\u4f7f\u7528\u547d\u4ee4 <code>sudo apt install python3<\/code> \u6765\u5b89\u88c5Python3\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165 <code>python3 --version<\/code> \u6765\u786e\u8ba4\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u53ef\u4ee5\u5728\u6811\u8393\u6d3e\u4e0a\u4f7f\u7528\u54ea\u4e9b\u7248\u672c\u7684Python3\uff1f<\/strong><br \/>\u6811\u8393\u6d3e\u901a\u5e38\u652f\u6301\u591a\u4e2a\u7248\u672c\u7684Python3\u3002\u6700\u65b0\u7248\u672c\u7684Raspberry Pi OS\u901a\u5e38\u4f1a\u9884\u88c5Python3\u7684\u6700\u65b0\u7a33\u5b9a\u7248\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 <code>apt list --upgradable<\/code> \u6765\u67e5\u770b\u53ef\u7528\u7684\u66f4\u65b0\u7248\u672c\u3002\u5982\u679c\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684Python3\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528<code>pyenv<\/code>\u5de5\u5177\u6765\u7ba1\u7406\u548c\u5b89\u88c5\u4e0d\u540c\u7248\u672c\u3002<\/p>\n<p><strong>\u5b89\u88c5Python3\u540e\uff0c\u5982\u4f55\u5b89\u88c5\u989d\u5916\u7684\u5e93\u548c\u6a21\u5757\uff1f<\/strong><br \/>\u5728\u6811\u8393\u6d3e\u4e0a\u5b89\u88c5\u5b8cPython3\u540e\uff0c\u4f7f\u7528<code>pip<\/code>\u53ef\u4ee5\u65b9\u4fbf\u5730\u5b89\u88c5\u989d\u5916\u7684\u5e93\u548c\u6a21\u5757\u3002\u786e\u4fdd\u5148\u5b89\u88c5<code>pip<\/code>\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 <code>sudo apt install python3-pip<\/code> \u6765\u5b8c\u6210\u3002\u5b89\u88c5\u597d<code>pip<\/code>\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>pip3 install package_name<\/code> \u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684\u5e93\uff0c\u4f8b\u5982 <code>pip3 install numpy<\/code> \u6765\u5b89\u88c5NumPy\u5e93\uff0c\u65b9\u4fbf\u8fdb\u884c\u79d1\u5b66\u8ba1\u7b97\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u6811\u8393\u6d3e\u4e2d\u5b89\u88c5Python3\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u68c0\u67e5\u5f53\u524d\u7248\u672c\u3001\u66f4\u65b0\u8f6f\u4ef6\u5305\u3001\u5b89\u88c5Python3\u3001\u9a8c\u8bc1\u5b89\u88c5\u3002 \u5176\u4e2d\uff0c\u66f4\u65b0\u8f6f\u4ef6 [&hellip;]","protected":false},"author":3,"featured_media":1082261,"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\/1082252"}],"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=1082252"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1082252\/revisions"}],"predecessor-version":[{"id":1082262,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1082252\/revisions\/1082262"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1082261"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1082252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1082252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1082252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}