{"id":1009549,"date":"2024-12-27T11:12:44","date_gmt":"2024-12-27T03:12:44","guid":{"rendered":""},"modified":"2024-12-27T11:12:46","modified_gmt":"2024-12-27T03:12:46","slug":"linux%e4%b8%ad%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1009549.html","title":{"rendered":"Linux\u4e2d\u5982\u4f55\u6253\u5f00Python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25084433\/3b10c2fe-eef8-4685-a9e3-4419a6b7e3ba.webp\" alt=\"Linux\u4e2d\u5982\u4f55\u6253\u5f00Python\" \/><\/p>\n<p><p> <strong>\u5728Linux\u4e2d\u6253\u5f00Python\u7684\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u3001\u901a\u8fc7\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u4f7f\u7528Python\u811a\u672c\u6587\u4ef6\u3002<\/strong>\u5176\u4e2d\uff0c\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3aLinux\u7cfb\u7edf\u901a\u5e38\u81ea\u5e26Python\u89e3\u91ca\u5668\uff0c\u7528\u6237\u53ea\u9700\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u76f8\u5e94\u547d\u4ee4\u5373\u53ef\u542f\u52a8Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u7ec8\u7aef\u547d\u4ee4\u6253\u5f00Python\uff0c\u5e76\u63d0\u4f9b\u4e00\u4e9b\u5173\u4e8ePython\u73af\u5883\u7ba1\u7406\u7684\u6280\u5de7\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u6253\u5f00Python<\/p>\n<\/p>\n<p><p>\u5728Linux\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u6765\u542f\u52a8Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002\u901a\u5e38\uff0cLinux\u7cfb\u7edf\u81ea\u5e26Python 2\u548cPython 3\u4e24\u4e2a\u7248\u672c\uff0c\u56e0\u6b64\u60a8\u9700\u8981\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528Python 3<\/li>\n<\/ol>\n<p><p>\u4e3a\u4e86\u786e\u4fdd\u60a8\u4f7f\u7528\u7684\u662fPython 3\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u542f\u52a8Python 3\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u67e5\u770b\u5176\u8f93\u51fa\u3002\u8f93\u5165 <code>exit()<\/code> \u6216\u6309 <code>Ctrl + D<\/code> \u53ef\u4ee5\u9000\u51fa\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u4f7f\u7528Python 2<\/li>\n<\/ol>\n<p><p>\u5982\u679c\u60a8\u9700\u8981\u4f7f\u7528Python 2\uff08\u5c3d\u7ba1Python 2\u5df2\u505c\u6b62\u652f\u6301\uff09\uff0c\u53ef\u4ee5\u8f93\u5165\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6ce8\u610f\uff0c\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\uff0c\u67d0\u4e9b\u53d1\u884c\u7248\u53ef\u80fd\u53ea\u5b89\u88c5\u4e86Python 3\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>\u68c0\u67e5Python\u7248\u672c<\/li>\n<\/ol>\n<p><p>\u5728\u542f\u52a8Python\u4e4b\u524d\uff0c\u60a8\u53ef\u80fd\u5e0c\u671b\u786e\u8ba4\u7cfb\u7edf\u4e2d\u5b89\u88c5\u7684Python\u7248\u672c\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bPython 3\u7684\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5bf9\u4e8ePython 2\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u73b0\u4ee3\u5f00\u53d1\u4e2d\uff0c\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u662f\u5e38\u89c1\u9700\u6c42\u3002\u4f7f\u7528\u5de5\u5177\u5982 <code>pyenv<\/code>\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u5728\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\u5207\u6362\u3002<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5 <code>pyenv<\/code><\/li>\n<\/ol>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86 <code>git<\/code> \u548c <code>curl<\/code>\uff0c\u7136\u540e\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u5b89\u88c5 <code>pyenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">curl https:\/\/pyenv.run | bash<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6309\u7167\u63d0\u793a\u4fee\u6539\u60a8\u7684 <code>~\/.bashrc<\/code> \u6216 <code>~\/.zshrc<\/code> \u6587\u4ef6\u4ee5\u4fbf\u547d\u4ee4\u884c\u80fd\u591f\u8bc6\u522b <code>pyenv<\/code> \u547d\u4ee4\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u4f7f\u7528 <code>pyenv<\/code> \u5b89\u88c5\u548c\u7ba1\u7406Python\u7248\u672c<\/li>\n<\/ol>\n<p><p>\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.8.10<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8bbe\u7f6e\u5168\u5c40\u6216\u672c\u5730\u7684Python\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv global 3.8.10<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5728\u7279\u5b9a\u9879\u76ee\u76ee\u5f55\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv local 3.8.10<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528 <code>pyenv<\/code> \u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5728\u4e0d\u540c\u9879\u76ee\u4e2d\u4f7f\u7528\u4e0d\u540c\u7684Python\u7248\u672c\uff0c\u907f\u514d\u7248\u672c\u51b2\u7a81\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u901a\u8fc7\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6253\u5f00Python<\/p>\n<\/p>\n<p><p>\u8bb8\u591a\u5f00\u53d1\u8005\u4f7f\u7528IDE\u6765\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002IDE\u901a\u5e38\u63d0\u4f9b\u4e86\u66f4\u4e3a\u53cb\u597d\u7684\u7528\u6237\u754c\u9762\u548c\u66f4\u5f3a\u5927\u7684\u8c03\u8bd5\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528PyCharm<\/li>\n<\/ol>\n<p><p>PyCharm\u662fJetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u516c\u53f8\u51fa\u54c1\u7684\u4e00\u6b3e\u4e13\u4e1aPython\u5f00\u53d1\u73af\u5883\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5728Linux\u4e0a\u5b89\u88c5\u5e76\u4f7f\u7528PyCharm\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4e0b\u8f7dPyCharm\uff1a\u8bbf\u95eeJetBrains\u5b98\u7f51\uff0c\u6839\u636e\u60a8\u7684Linux\u53d1\u884c\u7248\u4e0b\u8f7d\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u3002<\/li>\n<li>\u5b89\u88c5\uff1a\u89e3\u538b\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\uff0c\u7136\u540e\u8fd0\u884c <code>bin\/pycharm.sh<\/code> \u542f\u52a8PyCharm\u3002<\/li>\n<li>\u914d\u7f6ePython\u89e3\u91ca\u5668\uff1a\u5728PyCharm\u4e2d\u521b\u5efa\u65b0\u9879\u76ee\u65f6\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u7cfb\u7edf\u4e2d\u7684Python\u89e3\u91ca\u5668\uff0c\u6216\u8005\u901a\u8fc7PyCharm\u7684\u8bbe\u7f6e\u754c\u9762\u6dfb\u52a0\u65b0\u7684\u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>\u4f7f\u7528Visual Studio Code<\/li>\n<\/ol>\n<p><p>Visual Studio Code\uff08VSCode\uff09\u662f\u53e6\u4e00\u6b3e\u6d41\u884c\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u5b83\u901a\u8fc7\u6269\u5c55\u63d0\u4f9b\u4e86\u826f\u597d\u7684Python\u652f\u6301\u3002<\/p>\n<\/p>\n<ul>\n<li>\u5b89\u88c5VSCode\uff1a\u8bbf\u95eeVisual Studio Code\u5b98\u7f51\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u7528\u4e8eLinux\u7684\u7248\u672c\u3002<\/li>\n<li>\u5b89\u88c5Python\u6269\u5c55\uff1a\u542f\u52a8VSCode\u540e\uff0c\u8bbf\u95ee\u6269\u5c55\u5e02\u573a\uff0c\u641c\u7d22\u5e76\u5b89\u88c5Python\u6269\u5c55\u3002<\/li>\n<li>\u914d\u7f6ePython\u89e3\u91ca\u5668\uff1a\u901a\u8fc7\u547d\u4ee4\u9762\u677f\u6216\u8bbe\u7f6e\u754c\u9762\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u7cfb\u7edf\u4e2d\u7684Python\u89e3\u91ca\u5668\u3002<\/li>\n<\/ul>\n<p><p><strong>\u9009\u62e9\u9002\u5408\u7684IDE\u6216\u7f16\u8f91\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684IDE\u6216\u7f16\u8f91\u5668\u662f\u63d0\u5347\u5f00\u53d1\u6548\u7387\u7684\u91cd\u8981\u56e0\u7d20\u3002PyCharm\u63d0\u4f9b\u4e86\u5168\u9762\u7684\u529f\u80fd\u652f\u6301\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u7684\u5f00\u53d1\uff1b\u800cVSCode\u5219\u4ee5\u8f7b\u91cf\u7ea7\u548c\u591a\u8bed\u8a00\u652f\u6301\u8457\u79f0\uff0c\u9002\u5408\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u7684\u5f00\u53d1\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528Python\u811a\u672c\u6587\u4ef6<\/p>\n<\/p>\n<p><p>\u5728Linux\u4e2d\uff0c\u9664\u4e86\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6\u3002\u8fd9\u79cd\u65b9\u5f0f\u9002\u7528\u4e8e\u9700\u8981\u6279\u5904\u7406\u6267\u884cPython\u4ee3\u7801\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<ol>\n<li>\u521b\u5efaPython\u811a\u672c\u6587\u4ef6<\/li>\n<\/ol>\n<p><p>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982 <code>nano<\/code>\u3001<code>vim<\/code> \u6216 <code>gedit<\/code>\uff09\u521b\u5efa\u4e00\u4e2aPython\u811a\u672c\u6587\u4ef6\uff0c\u901a\u5e38\u4ee5 <code>.py<\/code> \u4e3a\u6269\u5c55\u540d\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a <code>hello.py<\/code> \u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6<\/li>\n<\/ol>\n<p><p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u5bfc\u822a\u5230\u811a\u672c\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884cPython\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4f7f\u7528Python 2\uff0c\u5219\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u811a\u672c\u6267\u884c\u6743\u9650<\/strong><\/p>\n<\/p>\n<p><p>\u5728Linux\u4e2d\uff0c\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u6587\u4ef6\u6743\u9650\uff0c\u4f7fPython\u811a\u672c\u6587\u4ef6\u53ef\u4ee5\u76f4\u63a5\u6267\u884c\u3002\u9996\u5148\uff0c\u5728\u811a\u672c\u6587\u4ef6\u9876\u90e8\u6dfb\u52a0\u5982\u4e0b\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">#!\/usr\/bin\/env python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6388\u4e88\u6267\u884c\u6743\u9650\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">chmod +x hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u76f4\u63a5\u8fd0\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u4f7f\u811a\u672c\u66f4\u5177\u53ef\u79fb\u690d\u6027\uff0c\u9002\u7528\u4e8e\u5728\u4e0d\u540c\u7cfb\u7edf\u73af\u5883\u4e2d\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u603b\u7ed3\u4e0e\u5efa\u8bae<\/p>\n<\/p>\n<p><p>Linux\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u5f0f\u6765\u6253\u5f00\u548c\u8fd0\u884cPython\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u8eab\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u3002<strong>\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u662f\u6700\u57fa\u672c\u4e5f\u662f\u6700\u5e38\u7528\u7684\u65b9\u5f0f\uff0c\u9002\u5408\u5feb\u901f\u6d4b\u8bd5\u548c\u5f00\u53d1\uff1b\u4f7f\u7528IDE\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u5f00\u53d1\u5de5\u5177\u548c\u8c03\u8bd5\u529f\u80fd\uff0c\u9002\u5408\u590d\u6742\u9879\u76ee\u5f00\u53d1\uff1b\u800c\u76f4\u63a5\u8fd0\u884cPython\u811a\u672c\u5219\u9002\u7528\u4e8e\u81ea\u52a8\u5316\u4efb\u52a1\u548c\u6279\u5904\u7406\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b66\u4e60\u548c\u4f7f\u7528Python\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5efa\u8bae\u5173\u6ce8\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b66\u4e60\u57fa\u7840\u547d\u4ee4\u884c\u64cd\u4f5c<\/strong>\uff1a\u719f\u6089Linux\u547d\u4ee4\u884c\u64cd\u4f5c\u53ef\u4ee5\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u6587\u4ef6\u548c\u76ee\u5f55\u65f6\u3002<\/li>\n<li><strong>\u7ba1\u7406Python\u5305\u548c\u73af\u5883<\/strong>\uff1a\u4f7f\u7528 <code>pip<\/code> \u548c <code>virtualenv<\/code> \u6216 <code>venv<\/code> \u6765\u7ba1\u7406Python\u5305\u548c\u865a\u62df\u73af\u5883\uff0c\u907f\u514d\u5305\u51b2\u7a81\u548c\u73af\u5883\u6c61\u67d3\u3002<\/li>\n<li><strong>\u4fdd\u6301\u5b66\u4e60\u548c\u63a2\u7d22<\/strong>\uff1aPython\u751f\u6001\u7cfb\u7edf\u975e\u5e38\u4e30\u5bcc\uff0c\u6301\u7eed\u5b66\u4e60\u65b0\u77e5\u8bc6\u548c\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5728\u5f00\u53d1\u4e2d\u66f4\u597d\u5730\u89e3\u51b3\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u7cfb\u7edf\u5730\u5b66\u4e60\u548c\u5b9e\u8df5\uff0c\u60a8\u5c06\u80fd\u591f\u5728Linux\u73af\u5883\u4e2d\u9ad8\u6548\u5730\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u548c\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Linux\u4e2d\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728Linux\u4e2d\u5b89\u88c5Python\u975e\u5e38\u7b80\u5355\u3002\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u9ed8\u8ba4\u5df2\u7ecf\u9884\u88c5\u4e86Python\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u68c0\u67e5\u662f\u5426\u5df2\u5b89\u88c5\u3002\u5982\u679c\u6ca1\u6709\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5982<code>apt<\/code>\uff08\u5bf9\u4e8eDebian\/Ubuntu\uff09\u6216<code>yum<\/code>\uff08\u5bf9\u4e8eCentOS\/Fedora\uff09\uff0c\u8fd0\u884c\u547d\u4ee4<code>sudo apt install python3<\/code>\u6216<code>sudo yum install python3<\/code>\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Linux\u4e2d\u4f7f\u7528Python\u7f16\u5199\u548c\u8fd0\u884c\u811a\u672c\uff1f<\/strong><br \/>\u7f16\u5199Python\u811a\u672c\u53ea\u9700\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982Vim\u3001Nano\u6216\u4efb\u4f55\u56fe\u5f62\u754c\u9762\u7684\u7f16\u8f91\u5668\uff09\u521b\u5efa\u4e00\u4e2a\u4ee5<code>.py<\/code>\u7ed3\u5c3e\u7684\u6587\u4ef6\u3002\u6bd4\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528<code>nano myscript.py<\/code>\u547d\u4ee4\u521b\u5efa\u5e76\u7f16\u8f91\u6587\u4ef6\u3002\u5728\u6587\u4ef6\u4e2d\u5199\u5165Python\u4ee3\u7801\u540e\uff0c\u4fdd\u5b58\u5e76\u9000\u51fa\u3002\u8981\u8fd0\u884c\u811a\u672c\uff0c\u8bf7\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python3 myscript.py<\/code>\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Linux\u4e2d\u7ba1\u7406Python\u7684\u5305\u548c\u73af\u5883\uff1f<\/strong><br \/>\u4f7f\u7528<code>pip<\/code>\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406Python\u5305\u3002\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>pip install package_name<\/code>\u6765\u5b89\u88c5\u6240\u9700\u7684\u5305\u3002\u4e3a\u4e86\u66f4\u597d\u5730\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\uff0c\u5efa\u8bae\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python3 -m venv myenv<\/code>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u6fc0\u6d3b\u5b83\u540e\uff08\u4f7f\u7528<code>source myenv\/bin\/activate<\/code>\uff09\uff0c\u60a8\u5c31\u53ef\u4ee5\u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\u548c\u7ba1\u7406\u5305\uff0c\u800c\u4e0d\u5f71\u54cd\u5168\u5c40\u7684Python\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u4e2d\u6253\u5f00Python\u7684\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u3001\u901a\u8fc7\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3001\u4f7f\u7528Python\u811a\u672c\u6587\u4ef6\u3002\u5176 [&hellip;]","protected":false},"author":3,"featured_media":1009555,"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\/1009549"}],"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=1009549"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1009549\/revisions"}],"predecessor-version":[{"id":1009557,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1009549\/revisions\/1009557"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1009555"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1009549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1009549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1009549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}