{"id":942268,"date":"2024-12-26T21:57:50","date_gmt":"2024-12-26T13:57:50","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/942268.html"},"modified":"2024-12-26T21:57:51","modified_gmt":"2024-12-26T13:57:51","slug":"termux%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/942268.html","title":{"rendered":"termux\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\/25080143\/76646c95-3af3-41dc-9f0b-78e9db0061f1.webp\" alt=\"termux\u5982\u4f55\u6253\u5f00python\" \/><\/p>\n<p><p> <strong>\u5728Termux\u4e2d\u6253\u5f00Python\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Termux\u3001\u66f4\u65b0\u8f6f\u4ef6\u5305\u3001\u5b89\u88c5Python\u3001\u4f7f\u7528<code>python<\/code>\u547d\u4ee4\u542f\u52a8\u3002<\/strong>\u5728\u8fd9\u4e9b\u6b65\u9aa4\u4e2d\uff0c\u5b89\u88c5Python\u662f\u5173\u952e\uff0c\u56e0\u4e3aTermux\u9ed8\u8ba4\u5e76\u4e0d\u9884\u88c5Python\u3002\u5b89\u88c5Python\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u7b80\u5355\u7684\u547d\u4ee4\u6765\u542f\u52a8\u548c\u8fd0\u884cPython\u73af\u5883\u3002\u5728\u4e0b\u9762\u7684\u5185\u5bb9\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5\u4e0e\u66f4\u65b0Termux<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4f7f\u7528Python\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u7684\u8bbe\u5907\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Termux\u3002Termux\u53ef\u4ee5\u901a\u8fc7Google Play Store\u6216F-Droid\u4e0b\u8f7d\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00Termux\u5e76\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u66f4\u65b0\u8f6f\u4ef6\u5305\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pkg update<\/p>\n<p>pkg upgrade<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e24\u6761\u547d\u4ee4\u4f1a\u66f4\u65b0Termux\u7684\u8f6f\u4ef6\u5305\u7d22\u5f15\u5e76\u5347\u7ea7\u6240\u6709\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\uff0c\u786e\u4fdd\u4f60\u62e5\u6709\u6700\u65b0\u7684\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u5b89\u88c5Python<\/p>\n<\/p>\n<p><p>\u5728Termux\u4e2d\u5b89\u88c5Python\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pkg install python<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u5b89\u88c5Python\u7684\u6700\u65b0\u7248\u672c\u4ee5\u53ca\u76f8\u5173\u7684\u5305\u7ba1\u7406\u5de5\u5177pip\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>python --version<\/code>\u547d\u4ee4\u6765\u9a8c\u8bc1Python\u662f\u5426\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u542f\u52a8Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728Termux\u4e2d\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u6765\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>\u8fd9\u5c06\u6253\u5f00Python\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\uff0c\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u6267\u884cPython\u4ee3\u7801\u3002\u4f60\u53ef\u4ee5\u8f93\u5165\u7b80\u5355\u7684Python\u547d\u4ee4\u6765\u6d4b\u8bd5\uff0c\u6bd4\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, Termux!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u7ba1\u7406Python\u5305<\/p>\n<\/p>\n<p><p>\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u65f6\uff0c\u5f80\u5f80\u9700\u8981\u5b89\u88c5\u989d\u5916\u7684\u5305\u3002\u53ef\u4ee5\u4f7f\u7528pip\u6765\u7ba1\u7406\u8fd9\u4e9b\u5305\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684pip\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5\u5305\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">pip install package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u5378\u8f7d\u5305\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">pip uninstall package_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u5217\u51fa\u5df2\u5b89\u88c5\u7684\u5305\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">pip list<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u7f16\u5199\u548c\u8fd0\u884cPython\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728Termux\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982nano\u6216vim\uff09\u6765\u7f16\u5199Python\u811a\u672c\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528nano\u521b\u5efa\u4e00\u4e2aPython\u811a\u672c\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">nano my_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\n<p>\u5728nano\u4e2d\u7f16\u5199\u4f60\u7684Python\u4ee3\u7801\uff0c\u7136\u540e\u6309<code>Ctrl + X<\/code>\uff0c\u6309<code>Y<\/code>\u786e\u8ba4\u4fdd\u5b58\u5e76\u9000\u51fa\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u8fd0\u884c\u4f60\u7684Python\u811a\u672c\uff1a<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-bash\">python my_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u63d0\u9ad8Python\u5f00\u53d1\u6548\u7387<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728\u5f00\u53d1\u591a\u4e2a\u9879\u76ee\u65f6\uff0c\u4f7f\u7528Python\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7ba1\u7406\u4e0d\u540c\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\u3002\u53ef\u4ee5\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u6765\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u81ea\u52a8\u5316\u5de5\u5177<\/strong>\uff1a\u4f7f\u7528Makefile\u6216\u5176\u4ed6\u81ea\u52a8\u5316\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u4f60\u7b80\u5316\u5e38\u89c1\u4efb\u52a1\uff0c\u4f8b\u5982\u6d4b\u8bd5\u3001\u6784\u5efa\u548c\u90e8\u7f72\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u5de5\u5177<\/strong>\uff1a\u5584\u7528Python\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5982<code>pdb<\/code>\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u5feb\u5730\u5b9a\u4f4d\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5931\u8d25<\/strong>\uff1a\u5982\u679c\u5728\u5b89\u88c5Python\u6216\u5176\u4ed6\u5305\u65f6\u9047\u5230\u9519\u8bef\uff0c\u9996\u5148\u786e\u4fddTermux\u5df2\u66f4\u65b0\u3002\u5982\u679c\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u5e76\u5c1d\u8bd5\u66f4\u6362\u955c\u50cf\u6e90\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\u5728Termux\u4e2d\uff0c\u67d0\u4e9b\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u7279\u5b9a\u7684\u6743\u9650\u3002\u786e\u4fddTermux\u5728\u8bbe\u5907\u4e0a\u62e5\u6709\u5fc5\u8981\u7684\u6743\u9650\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u517c\u5bb9\u6027\u95ee\u9898<\/strong>\uff1a\u67d0\u4e9bPython\u5305\u53ef\u80fd\u4e0d\u652f\u6301ARM\u67b6\u6784\u7684\u8bbe\u5907\uff0c\u5c1d\u8bd5\u5bfb\u627e\u66ff\u4ee3\u5305\u6216\u5728\u652f\u6301\u7684\u5e73\u53f0\u4e0a\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516b\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>Termux\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u73af\u5883\uff0c\u4f7f\u5f97\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u8fd0\u884cPython\u53d8\u5f97\u975e\u5e38\u65b9\u4fbf\u3002\u901a\u8fc7\u9075\u5faa\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u5728Termux\u4e2d\u5b89\u88c5\u548c\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u811a\u672c\u7f16\u5199\u8fd8\u662f\u590d\u6742\u7684\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\uff0cTermux\u90fd\u80fd\u63d0\u4f9b\u6240\u9700\u7684\u5de5\u5177\u548c\u7075\u6d3b\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Termux\u4e2d\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728Termux\u4e2d\u5b89\u88c5Python\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u6253\u5f00Termux\u5e94\u7528\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5373\u53ef\uff1a  <\/p>\n<pre><code class=\"language-bash\">pkg install python\n<\/code><\/pre>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u6765\u542f\u52a8Python\u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>\u5728Termux\u4e2d\u8fd0\u884cPython\u811a\u672c\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u8fd0\u884cPython\u811a\u672c\u5728Termux\u4e2d\u662f\u76f4\u63a5\u7684\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u6709\u4e00\u4e2aPython\u811a\u672c\u6587\u4ef6\uff0c\u6bd4\u5982<code>script.py<\/code>\u3002\u7136\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u5b83\uff1a  <\/p>\n<pre><code class=\"language-bash\">python script.py\n<\/code><\/pre>\n<p>\u5982\u679c\u811a\u672c\u6ca1\u6709\u9519\u8bef\uff0c\u5b83\u5c06\u987a\u5229\u6267\u884c\u5e76\u663e\u793a\u8f93\u51fa\u3002<\/p>\n<p><strong>Termux\u4e2d\u5982\u4f55\u7ba1\u7406Python\u7684\u5305\u548c\u5e93\uff1f<\/strong><br \/>\u5728Termux\u4e2d\u7ba1\u7406Python\u5305\u975e\u5e38\u65b9\u4fbf\u3002\u53ef\u4ee5\u4f7f\u7528<code>pip<\/code>\u5de5\u5177\u6765\u5b89\u88c5\u548c\u7ba1\u7406\u5e93\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86<code>pip<\/code>\uff0c\u7136\u540e\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u4efb\u4f55\u4f60\u9700\u8981\u7684\u5e93\uff1a  <\/p>\n<pre><code class=\"language-bash\">pip install package_name\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u901a\u8fc7<code>pip list<\/code>\u67e5\u770b\u5df2\u5b89\u88c5\u7684\u5e93\uff0c\u786e\u4fdd\u4f60\u80fd\u591f\u8f7b\u677e\u7ba1\u7406\u4f60\u7684Python\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Termux\u4e2d\u6253\u5f00Python\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Termux\u3001\u66f4\u65b0\u8f6f\u4ef6\u5305\u3001\u5b89\u88c5Python\u3001\u4f7f\u7528python\u547d [&hellip;]","protected":false},"author":3,"featured_media":942270,"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\/942268"}],"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=942268"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/942268\/revisions"}],"predecessor-version":[{"id":942273,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/942268\/revisions\/942273"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/942270"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=942268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=942268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=942268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}