{"id":1007907,"date":"2024-12-27T10:57:59","date_gmt":"2024-12-27T02:57:59","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1007907.html"},"modified":"2024-12-27T10:58:04","modified_gmt":"2024-12-27T02:58:04","slug":"linux%e4%b8%8bpython%e5%a6%82%e4%bd%95%e5%90%af%e5%8a%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1007907.html","title":{"rendered":"linux\u4e0bpython\u5982\u4f55\u542f\u52a8"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25083428\/93698578-ea00-4316-894c-e910617e6b16.webp\" alt=\"linux\u4e0bpython\u5982\u4f55\u542f\u52a8\" \/><\/p>\n<p><p> <strong>\u5728Linux\u4e0b\u542f\u52a8Python\u7684\u4e3b\u8981\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u3001\u4f7f\u7528Python\u811a\u672c\u6587\u4ef6\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002<\/strong> \u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u76f4\u63a5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u547d\u4ee4\u542f\u52a8Python\u89e3\u91ca\u5668\u3002\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u901a\u5e38\u4f1a\u9884\u88c5Python\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u76f4\u63a5\u8bbf\u95eePython\u89e3\u91ca\u5668\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199Python\u811a\u672c\u6587\u4ef6\u5e76\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u8fd9\u4e9b\u6587\u4ef6\u6765\u542f\u52a8Python\u7a0b\u5e8f\u3002\u4e3a\u4e86\u66f4\u597d\u5730\u7ba1\u7406Python\u9879\u76ee\u4e2d\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u7528\u6237\u4e5f\u53ef\u4ee5\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u542f\u52a8Python<\/p>\n<\/p>\n<p><p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u7ec8\u7aef\u662f\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u4ea4\u4e92\u7684\u4e3b\u8981\u65b9\u5f0f\u4e4b\u4e00\u3002\u901a\u8fc7\u7ec8\u7aef\u53ef\u4ee5\u76f4\u63a5\u542f\u52a8Python\u89e3\u91ca\u5668\uff0c\u8fd9\u79cd\u65b9\u5f0f\u975e\u5e38\u9002\u5408\u8fdb\u884c\u7b80\u5355\u7684\u4ea4\u4e92\u5f0f\u7f16\u7a0b\u6216\u6d4b\u8bd5\u4ee3\u7801\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u67e5\u770bPython\u7248\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u542f\u52a8Python\u4e4b\u524d\uff0c\u901a\u5e38\u9700\u8981\u786e\u8ba4\u7cfb\u7edf\u4e2d\u5df2\u5b89\u88c5Python\u5e76\u68c0\u67e5\u5176\u7248\u672c\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770bPython\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7531\u4e8ePython 2.x\u7248\u672c\u5df2\u7ecf\u505c\u6b62\u7ef4\u62a4\uff0c\u5efa\u8bae\u4f7f\u7528Python 3.x\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8Python\u89e3\u91ca\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u65e6\u786e\u8ba4Python\u5df2\u5b89\u88c5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Python\u89e3\u91ca\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6267\u884c\u4ee5\u4e0a\u547d\u4ee4\u540e\uff0c\u60a8\u5c06\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u73af\u5883\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u67e5\u770b\u8f93\u51fa\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51faPython\u89e3\u91ca\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u9000\u51faPython\u89e3\u91ca\u5668\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">exit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u6309\u4e0b<code>Ctrl + D<\/code>\u7ec4\u5408\u952e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u901a\u8fc7Python\u811a\u672c\u6587\u4ef6\u542f\u52a8<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u7a0b\u5e8f\uff0c\u901a\u5e38\u4f1a\u7f16\u5199Python\u811a\u672c\u6587\u4ef6\u5e76\u901a\u8fc7\u7ec8\u7aef\u6267\u884c\u8fd9\u4e9b\u6587\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f16\u5199Python\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982vim\u3001nano\u6216gedit\uff09\u7f16\u5199Python\u811a\u672c\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>example.py<\/code>\u7684\u6587\u4ef6\uff0c\u5e76\u7f16\u5199\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># example.py<\/p>\n<p>print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u7ec8\u7aef\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python3 example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u8f93\u51fa<code>Hello, World!<\/code>\u5230\u7ec8\u7aef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1Python\u9879\u76ee\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u60a8\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u7248\u672c\u51b2\u7a81\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\u786e\u4fdd\u5df2\u5b89\u88c5<code>venv<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\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>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\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\u60a8\u5c06\u5728\u7ec8\u7aef\u63d0\u793a\u7b26\u524d\u770b\u5230\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u8868\u793a\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u8be5\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728\u865a\u62df\u73af\u5883\u4e2d\u542f\u52a8Python<\/strong><\/p>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<code>python<\/code>\u547d\u4ee4\u542f\u52a8Python\u89e3\u91ca\u5668\uff0c\u6216\u8fd0\u884cPython\u811a\u672c\u3002\u6b64\u65f6\uff0c\u6240\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u548c\u5b89\u88c5\u7684\u4f9d\u8d56\u5e93\u90fd\u5c06\u4e0e\u865a\u62df\u73af\u5883\u9694\u79bb\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\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<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5b89\u88c5\u548c\u7ba1\u7406Python\u7248\u672c<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\uff0c\u6216\u8005\u5b89\u88c5\u7279\u5b9a\u7684Python\u7248\u672c\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u5de5\u5177\u5982<code>pyenv<\/code>\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5pyenv<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u5b89\u88c5\u4e86<code>pyenv<\/code>\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\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>\u7136\u540e\u6309\u7167\u63d0\u793a\u4fee\u6539\u60a8\u7684shell\u914d\u7f6e\u6587\u4ef6\uff08\u5982<code>.bashrc<\/code>\u6216<code>.bash_profile<\/code>\uff09\u4ee5\u52a0\u8f7d<code>pyenv<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>pyenv<\/code>\u53ef\u4ee5\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684Python\u3002\u4f8b\u5982\uff0c\u5b89\u88c5Python 3.8.6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv install 3.8.6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u5168\u5c40\u6216\u672c\u5730Python\u7248\u672c<\/strong><\/p>\n<\/p>\n<p><p>\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.8.6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u8bbe\u7f6e\u672c\u5730\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pyenv local 3.8.6<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5b89\u88c5Python\u5305\u7ba1\u7406\u5de5\u5177<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u65f6\uff0c\u901a\u5e38\u9700\u8981\u5b89\u88c5\u548c\u7ba1\u7406\u4e0d\u540c\u7684\u5305\u548c\u6a21\u5757\u3002<code>pip<\/code>\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u4e8e\u5b89\u88c5\u3001\u5347\u7ea7\u548c\u5220\u9664Python\u5305\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5pip<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0cPython 3.x\u7248\u672c\u5df2\u7ecf\u81ea\u5e26<code>pip<\/code>\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5<code>pip<\/code>\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip3 --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u3002\u4f8b\u5982\uff0c\u5728Debian\u6216Ubuntu\u7cfb\u7edf\u4e0a\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">sudo apt-get install python3-pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pip\u5b89\u88c5Python\u5305<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>pip<\/code>\u53ef\u4ee5\u5b89\u88c5\u5404\u79cdPython\u5305\u3002\u4f8b\u5982\uff0c\u5b89\u88c5<code>requests<\/code>\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5728\u5f53\u524dPython\u73af\u5883\u4e2d\u5b89\u88c5<code>requests<\/code>\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5347\u7ea7\u548c\u5378\u8f7dPython\u5305<\/strong><\/p>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5347\u7ea7\u6216\u5378\u8f7dPython\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install --upgrade requests<\/p>\n<p>pip uninstall requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/p>\n<\/p>\n<p><p>\u867d\u7136\u5728\u7ec8\u7aef\u4e2d\u53ef\u4ee5\u6267\u884cPython\u4ee3\u7801\u548c\u811a\u672c\uff0c\u4f46\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\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\u3001VS Code\u3001Jupyter Notebook\u7b49\u3002\u5b83\u4eec\u63d0\u4f9b\u4e86\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u3001\u7248\u672c\u63a7\u5236\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6eIDE<\/strong><\/p>\n<\/p>\n<p><p>\u914d\u7f6eIDE\u65f6\uff0c\u786e\u4fdd\u9009\u62e9\u6b63\u786e\u7684Python\u89e3\u91ca\u5668\u548c\u865a\u62df\u73af\u5883\uff0c\u4ee5\u4fbf\u4e0e\u9879\u76ee\u9700\u6c42\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u548c\u8c03\u8bd5Python\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528IDE\u53ef\u4ee5\u8f7b\u677e\u5730\u8fd0\u884c\u548c\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u5e2e\u52a9\u60a8\u5feb\u901f\u53d1\u73b0\u548c\u4fee\u590d\u9519\u8bef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u5728Linux\u4e0b\u542f\u52a8Python\u7684\u65b9\u6cd5\u591a\u6837\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u8fdb\u884cPython\u5f00\u53d1\u3002\u901a\u8fc7\u7ec8\u7aef\u547d\u4ee4\u3001\u811a\u672c\u6587\u4ef6\u3001\u865a\u62df\u73af\u5883\u3001\u7248\u672c\u7ba1\u7406\u5de5\u5177\u4ee5\u53caIDE\u7684\u7ed3\u5408\u4f7f\u7528\uff0c\u60a8\u53ef\u4ee5\u9ad8\u6548\u5730\u7ba1\u7406\u548c\u5f00\u53d1Python\u9879\u76ee\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728\u5927\u591a\u6570Linux\u53d1\u884c\u7248\u4e2d\uff0cPython\u901a\u5e38\u5df2\u7ecf\u9884\u88c5\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u7ec8\u7aef\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\u6765\u68c0\u67e5\u5f53\u524d\u5b89\u88c5\u7684\u7248\u672c\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\uff0c\u4f8b\u5982\u5728Ubuntu\u4e0a\u4f7f\u7528<code>sudo apt install python3<\/code>\u547d\u4ee4\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Linux\u7ec8\u7aef\u4e2d\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u8981\u5728Linux\u7ec8\u7aef\u4e2d\u8fd0\u884cPython\u811a\u672c\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u811a\u672c\u6587\u4ef6\u5177\u6709\u53ef\u6267\u884c\u6743\u9650\u3002\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4<code>chmod +x script.py<\/code>\u6765\u8bbe\u7f6e\u6743\u9650\u3002\u7136\u540e\uff0c\u901a\u8fc7\u8f93\u5165<code>.\/script.py<\/code>\u6765\u8fd0\u884c\u8be5\u811a\u672c\u3002\u5982\u679c\u60f3\u8981\u4f7f\u7528\u7279\u5b9a\u7248\u672c\u7684Python\uff0c\u53ef\u4ee5\u8f93\u5165<code>python3 script.py<\/code>\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Linux\u4e2d\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406Python\u9879\u76ee\uff1f<\/strong><br \/>\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u9694\u79bb\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u5728Linux\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7<code>python3 -m venv myenv<\/code>\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>myenv<\/code>\u7684\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>source myenv\/bin\/activate<\/code>\u547d\u4ee4\u3002\u6b64\u65f6\uff0c\u6240\u6709\u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\u7684\u5305\u90fd\u4f1a\u88ab\u9694\u79bb\uff0c\u4fbf\u4e8e\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Linux\u4e0b\u542f\u52a8Python\u7684\u4e3b\u8981\u65b9\u6cd5\u6709\uff1a\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u3001\u4f7f\u7528Python\u811a\u672c\u6587\u4ef6\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002 \u5176\u4e2d\uff0c\u6700\u5e38 [&hellip;]","protected":false},"author":3,"featured_media":1007921,"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\/1007907"}],"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=1007907"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1007907\/revisions"}],"predecessor-version":[{"id":1007922,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1007907\/revisions\/1007922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1007921"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1007907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1007907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1007907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}