{"id":938825,"date":"2024-12-26T20:20:06","date_gmt":"2024-12-26T12:20:06","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/938825.html"},"modified":"2024-12-26T20:20:08","modified_gmt":"2024-12-26T12:20:08","slug":"linux-%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cpython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/938825.html","title":{"rendered":"linux \u5982\u4f55\u8fd0\u884cpython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25074052\/6c7a7727-66c2-4e93-b691-410bf23b676b.webp\" alt=\"linux \u5982\u4f55\u8fd0\u884cpython\" \/><\/p>\n<p><p> <strong>\u5728Linux\u7cfb\u7edf\u4e0a\u8fd0\u884cPython\u7684\u65b9\u5f0f\u5305\u62ec\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u76f4\u63a5\u6267\u884cPython\u811a\u672c\u3001\u901a\u8fc7\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u8fd0\u884c\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528\u547d\u4ee4\u884c\u76f4\u63a5\u6267\u884cPython\u811a\u672c\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u5b83\u7684\u4f18\u70b9\u5728\u4e8e\u7b80\u5355\u76f4\u63a5\uff0c\u53ea\u9700\u786e\u4fddPython\u5df2\u5b89\u88c5\u5e76\u5728\u7cfb\u7edf\u8def\u5f84\u4e2d\u5373\u53ef\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e00\u65b9\u6cd5\uff0c\u5e76\u6269\u5c55\u5230\u5176\u5b83\u8fd0\u884c\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u6267\u884cPython\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c\u662f\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u3002\u9996\u5148\u786e\u4fdd\u5df2\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u68c0\u67e5\u7248\u672c\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5982<code>apt<\/code>\u6216<code>yum<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4fbf\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c\uff0c\u547d\u4ee4\u683c\u5f0f\u4e3a<code>python script.py<\/code>\u6216<code>python3 script.py<\/code>\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u5b89\u88c5\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u4e0e\u68c0\u67e5Python\u7248\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u4e2d\uff0cPython\u901a\u5e38\u5df2\u7ecf\u9884\u88c5\u3002\u4f46\u5728\u67d0\u4e9b\u8f7b\u91cf\u7ea7\u7cfb\u7edf\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u624b\u52a8\u5b89\u88c5\u3002\u4ee5Ubuntu\u4e3a\u4f8b\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Python 3\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt update<\/p>\n<p>sudo apt install python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5Python\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>\u786e\u4fdd\u8f93\u51fa\u663e\u793a\u6b63\u786e\u7684\u7248\u672c\u53f7\uff0c\u8fd9\u610f\u5473\u7740Python\u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u65e6\u786e\u8ba4Python\u5df2\u5b89\u88c5\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884cPython\u811a\u672c\u3002\u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a<code>example.py<\/code>\u7684Python\u811a\u672c\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, Linux!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u8be5\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd0\u884c\u540e\uff0c\u5c06\u4f1a\u5728\u7ec8\u7aef\u4e2d\u770b\u5230\u8f93\u51fa<code>Hello, Linux!<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>Linux\u73af\u5883\u4e2d\uff0cPython\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u8fd9\u5bf9\u4e8e\u5feb\u901f\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\u6216\u8fdb\u884c\u7b80\u5355\u7684\u6570\u5b66\u8ba1\u7b97\u975e\u5e38\u6709\u7528\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u542f\u52a8\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u542f\u52a8\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u542f\u52a8\u540e\uff0c\u5c06\u770b\u5230Python\u7684\u63d0\u793a\u7b26<code>&gt;&gt;&gt;<\/code>\uff0c\u8868\u793a\u5df2\u7ecf\u8fdb\u5165\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u3002\u5728\u8fd9\u4e2a\u6a21\u5f0f\u4e0b\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u67e5\u770b\u8f93\u51fa\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; print(&quot;Hello from the Python interpreter!&quot;)<\/p>\n<p>Hello from the Python interpreter!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u9000\u51faPython\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u4f7f\u7528<code>exit()<\/code>\u51fd\u6570\u6216\u952e\u5165\u5feb\u6377\u952e<code>Ctrl+D<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u9879\u76ee<\/p>\n<\/p>\n<p><p>\u5728Linux\u4e0a\u5f00\u53d1Python\u9879\u76ee\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u6709\u6548\u9694\u79bb\u9879\u76ee\u4f9d\u8d56\uff0c\u907f\u514d\u7248\u672c\u51b2\u7a81\u3002Python\u81ea\u5e26<code>venv<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u521b\u5efa\u865a\u62df\u73af\u5883\u540e\uff0c\u9700\u8981\u6fc0\u6d3b\u5b83\u4ee5\u4fbf\u5728\u5176\u9694\u79bb\u73af\u5883\u4e2d\u8fd0\u884cPython\u3002\u6fc0\u6d3b\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6fc0\u6d3b\u540e\uff0c\u547d\u4ee4\u63d0\u793a\u7b26\u4f1a\u6709\u4e00\u4e2a<code>(myenv)<\/code>\u7684\u524d\u7f00\uff0c\u8868\u793a\u5f53\u524d\u5904\u4e8e\u865a\u62df\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884cPython<\/strong><\/p>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u50cf\u5e73\u5e38\u4e00\u6837\u8fd0\u884cPython\u811a\u672c\u6216\u5b89\u88c5\u5305\u3002\u6240\u6709\u7684\u64cd\u4f5c\u90fd\u5c06\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fdb\u884c\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5230\u7cfb\u7edf\u7684Python\u73af\u5883\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">(myenv) python script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u5b8c\u6210\u5de5\u4f5c\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">deactivate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u9000\u51fa\u540e\uff0c\u547d\u4ee4\u63d0\u793a\u7b26\u5c06\u6062\u590d\u5230\u6b63\u5e38\u72b6\u6001\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u901a\u8fc7Shebang\u76f4\u63a5\u8fd0\u884cPython\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728Linux\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7Shebang\uff08<code>#!<\/code>\uff09\u5728\u811a\u672c\u7684\u7b2c\u4e00\u884c\u6307\u5b9a\u89e3\u91ca\u5668\u8def\u5f84\uff0c\u4f7f\u811a\u672c\u6587\u4ef6\u53d8\u5f97\u53ef\u6267\u884c\uff0c\u4ece\u800c\u65e0\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u660e\u786e\u6307\u5b9aPython\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6dfb\u52a0Shebang\u5230Python\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728Python\u811a\u672c\u7684\u7b2c\u4e00\u884c\u6dfb\u52a0\u4ee5\u4e0bShebang\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">#!\/usr\/bin\/env python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u884c\u4ee3\u7801\u544a\u8bc9\u7cfb\u7edf\u4f7f\u7528Python 3\u89e3\u91ca\u5668\u6765\u8fd0\u884c\u8fd9\u4e2a\u811a\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u66f4\u6539\u811a\u672c\u6743\u9650\u5e76\u8fd0\u884c<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u66f4\u6539\u811a\u672c\u7684\u6743\u9650\uff0c\u4f7f\u5176\u53ef\u6267\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">chmod +x script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">.\/script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u52bf\u5728\u4e8e\u811a\u672c\u53ef\u4ee5\u5728\u4efb\u4f55\u652f\u6301Shebang\u7684Unix-like\u7cfb\u7edf\u4e0a\u8fd0\u884c\uff0c\u800c\u65e0\u9700\u4fee\u6539\u547d\u4ee4\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528IDE\u6216\u6587\u672c\u7f16\u8f91\u5668\u8fd0\u884cPython<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u547d\u4ee4\u884c\uff0cLinux\u7528\u6237\u8fd8\u53ef\u4ee5\u5229\u7528\u5404\u79cd\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6216\u6587\u672c\u7f16\u8f91\u5668\u6765\u8fd0\u884cPython\u811a\u672c\uff0c\u8fd9\u4e9b\u5de5\u5177\u901a\u5e38\u63d0\u4f9b\u66f4\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u5982\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684IDE<\/strong><\/p>\n<\/p>\n<p><p>\u5e38\u7528\u7684Python IDE\u5305\u62ecPyCharm\u3001Visual Studio Code\u3001Eclipse\uff08\u7ed3\u5408PyDev\u63d2\u4ef6\uff09\u7b49\u3002\u8fd9\u4e9bIDE\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5f00\u53d1\u5de5\u5177\uff0c\u9002\u5408\u5927\u578b\u9879\u76ee\u7684\u5f00\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u8f7b\u91cf\u7ea7\u7684\u5f00\u53d1\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u5982Sublime Text\u3001Atom\u3001Vim\u6216Emacs\u3002\u8fd9\u4e9b\u7f16\u8f91\u5668\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u63d2\u4ef6\u6269\u5c55\u652f\u6301Python\u5f00\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u603b\u7ed3\uff1aLinux\u7cfb\u7edf\u4e0a\u8fd0\u884cPython\u811a\u672c\u7684\u65b9\u6cd5\u591a\u6837\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u6700\u5408\u9002\u7684\u65b9\u5f0f\u3002\u65e0\u8bba\u662f\u901a\u8fc7\u547d\u4ee4\u884c\u3001\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u8fd8\u662f\u4f7f\u7528\u865a\u62df\u73af\u5883\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u72ec\u7279\u7684\u4f18\u52bf\u548c\u9002\u7528\u573a\u666f\u3002\u638c\u63e1\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5c06\u6709\u52a9\u4e8e\u63d0\u9ad8Linux\u7cfb\u7edf\u4e0a\u7684Python\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Linux\u7cfb\u7edf\u4e2d\u5982\u4f55\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u4e2d\uff0cPython\u901a\u5e38\u4f1a\u9884\u88c5\u3002\u5982\u679c\u9700\u8981\u5b89\u88c5\u6700\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177\u3002\u5bf9\u4e8eDebian\u6216Ubuntu\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>sudo apt-get install python3<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u800c\u5bf9\u4e8eRed Hat\u6216CentOS\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528<code>sudo yum install python3<\/code>\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165<code>python3 --version<\/code>\u6765\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Linux\u4e2d\u521b\u5efa\u548c\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u521b\u5efaPython\u811a\u672c\u975e\u5e38\u7b80\u5355\u3002\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982vim\u3001nano\u6216gedit\uff09\u6765\u521b\u5efa\u4e00\u4e2a\u4ee5<code>.py<\/code>\u7ed3\u5c3e\u7684\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u547d\u4ee4<code>nano my_script.py<\/code>\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u3002\u5728\u6587\u4ef6\u4e2d\u7f16\u5199Python\u4ee3\u7801\u540e\uff0c\u4fdd\u5b58\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u3002\u8fd0\u884c\u811a\u672c\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u8f93\u5165<code>python3 my_script.py<\/code>\u6765\u5b8c\u6210\u3002<\/p>\n<p><strong>\u5728Linux\u4e2d\u5982\u4f55\u4f7f\u7528\u865a\u62df\u73af\u5883\u6765\u7ba1\u7406Python\u9879\u76ee\uff1f<\/strong><br \/>\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u53ef\u4ee5\u901a\u8fc7<code>python3 -m venv myenv<\/code>\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u65b9\u6cd5\u662f<code>source myenv\/bin\/activate<\/code>\u3002\u5728\u6fc0\u6d3b\u72b6\u6001\u4e0b\uff0c\u6240\u6709\u7684Python\u5305\u90fd\u5c06\u5b89\u88c5\u5728\u8be5\u73af\u5883\u4e2d\uff0c\u786e\u4fdd\u9879\u76ee\u4e4b\u95f4\u7684\u5e72\u6270\u6700\u5c0f\u5316\u3002\u8981\u9000\u51fa\u865a\u62df\u73af\u5883\uff0c\u53ea\u9700\u8f93\u5165<code>deactivate<\/code>\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u7cfb\u7edf\u4e0a\u8fd0\u884cPython\u7684\u65b9\u5f0f\u5305\u62ec\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u76f4\u63a5\u6267\u884cPython\u811a\u672c\u3001\u901a\u8fc7\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u8fd0\u884c\u3001\u4f7f\u7528\u865a [&hellip;]","protected":false},"author":3,"featured_media":938830,"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\/938825"}],"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=938825"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/938825\/revisions"}],"predecessor-version":[{"id":938833,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/938825\/revisions\/938833"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/938830"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=938825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=938825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=938825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}