{"id":990885,"date":"2024-12-27T08:23:56","date_gmt":"2024-12-27T00:23:56","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/990885.html"},"modified":"2024-12-27T08:23:58","modified_gmt":"2024-12-27T00:23:58","slug":"termux%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cpython%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/990885.html","title":{"rendered":"termux\u5982\u4f55\u8fd0\u884cpython\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25065423\/a2332cc0-3209-45b1-8763-f37847a608c5.webp\" alt=\"termux\u5982\u4f55\u8fd0\u884cpython\u6587\u4ef6\" \/><\/p>\n<p><p> <strong>\u5728Termux\u4e2d\u8fd0\u884cPython\u6587\u4ef6\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Termux\u548cPython\u3001\u521b\u5efaPython\u6587\u4ef6\u3001\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u8fd0\u884c\u6587\u4ef6\u3002<\/strong>\u9996\u5148\uff0c\u786e\u4fddTermux\u548cPython\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u5176\u6b21\uff0c\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u521b\u5efa\u6216\u7f16\u8f91Python\u6587\u4ef6\uff0c\u6700\u540e\uff0c\u901a\u8fc7\u7ec8\u7aef\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c\u3002\u4e0b\u9762\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u6b65\u9aa4\u53ca\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5TERMUX\u548cPYTHON<\/p>\n<\/p>\n<p><p>\u8981\u5728Termux\u4e2d\u8fd0\u884cPython\u6587\u4ef6\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u6b63\u786e\u5b89\u88c5Termux\u5e94\u7528\u7a0b\u5e8f\u53ca\u5176Python\u5305\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Termux<\/strong><\/p>\n<\/p>\n<p><p>Termux\u662f\u4e00\u6b3e\u9002\u7528\u4e8eAndroid\u8bbe\u5907\u7684\u7ec8\u7aef\u6a21\u62df\u5668\u3002\u8981\u5b89\u88c5Termux\uff0c\u53ef\u4ee5\u901a\u8fc7Google Play\u5546\u5e97\u6216F-Droid\u5e94\u7528\u5546\u5e97\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00Termux\u5e94\u7528\u4ee5\u7ee7\u7eed\u4e0b\u4e00\u6b65\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u66f4\u65b0\u548c\u5347\u7ea7\u5305<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Python\u4e4b\u524d\uff0c\u5efa\u8bae\u5148\u66f4\u65b0\u548c\u5347\u7ea7Termux\u4e2d\u7684\u6240\u6709\u8f6f\u4ef6\u5305\uff0c\u4ee5\u786e\u4fdd\u83b7\u53d6\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u8865\u4e01\u3002\u6253\u5f00Termux\u540e\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u66f4\u65b0\u548c\u5347\u7ea7\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pkg update &amp;&amp; pkg upgrade<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u786e\u4fddTermux\u73af\u5883\u5904\u4e8e\u6700\u65b0\u72b6\u6001\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong><\/p>\n<\/p>\n<p><p>Termux\u63d0\u4f9b\u4e86Python\u7684\u5b89\u88c5\u5305\u3002\u8981\u5b89\u88c5Python\uff0c\u8bf7\u8f93\u5165\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>\u6b64\u547d\u4ee4\u5c06\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u89e3\u91ca\u5668\uff0c\u5b8c\u6210\u540e\u4fbf\u53ef\u4ee5\u5728Termux\u4e2d\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u521b\u5efaPYTHON\u6587\u4ef6<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u4e86Python\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u9700\u8981\u521b\u5efa\u4e00\u4e2aPython\u6587\u4ef6\u6765\u7f16\u5199\u4ee3\u7801\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u6587\u672c\u7f16\u8f91\u5668<\/strong><\/p>\n<\/p>\n<p><p>Termux\u652f\u6301\u591a\u79cd\u6587\u672c\u7f16\u8f91\u5668\uff0c\u5982Nano\u3001Vim\u548cEmacs\u7b49\u3002Nano\u662f\u4e00\u4e2a\u7b80\u5355\u6613\u7528\u7684\u7f16\u8f91\u5668\uff0c\u9002\u5408\u521d\u5b66\u8005\u4f7f\u7528\u3002\u82e5\u5c1a\u672a\u5b89\u88c5Nano\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pkg install nano<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efaPython\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Nano\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\u3002\u5047\u8bbe\u8981\u521b\u5efa\u7684\u6587\u4ef6\u540d\u4e3a<code>example.py<\/code>\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">nano example.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u6253\u5f00Nano\u7f16\u8f91\u5668\uff0c\u5728\u5176\u4e2d\u53ef\u4ee5\u7f16\u5199Python\u4ee3\u7801\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\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>\u5b8c\u6210\u4ee3\u7801\u7f16\u5199\u540e\uff0c\u6309<code>CTRL + X<\/code>\u4fdd\u5b58\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u8fd0\u884cPYTHON\u6587\u4ef6<\/p>\n<\/p>\n<p><p>\u5b8c\u6210Python\u6587\u4ef6\u7684\u521b\u5efa\u540e\uff0c\u4fbf\u53ef\u4ee5\u5728Termux\u4e2d\u8fd0\u884c\u8be5\u6587\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5bfc\u822a\u5230\u6587\u4ef6\u6240\u5728\u76ee\u5f55<\/strong><\/p>\n<\/p>\n<p><p>\u786e\u4fdd\u5f53\u524d\u7ec8\u7aef\u8def\u5f84\u5728Python\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u3002\u5982\u679c\u4e0d\u786e\u5b9a\u5f53\u524d\u8def\u5f84\uff0c\u53ef\u4ee5\u4f7f\u7528<code>ls<\/code>\u547d\u4ee4\u5217\u51fa\u76ee\u5f55\u5185\u5bb9\uff0c\u6216\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5207\u6362\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u6587\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u8fd0\u884cPython\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>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u7ec8\u7aef\u5c06\u663e\u793aPython\u811a\u672c\u7684\u8f93\u51fa\u7ed3\u679c\u3002\u4f8b\u5982\uff0c\u663e\u793a\u201cHello, Termux!\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u8c03\u8bd5\u548c\u7ba1\u7406PYTHON\u73af\u5883<\/p>\n<\/p>\n<p><p>\u8fd0\u884cPython\u6587\u4ef6\u540e\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u9700\u8981\u8c03\u8bd5\u7684\u9519\u8bef\u6216\u9700\u8981\u7ba1\u7406Python\u73af\u5883\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u68c0\u67e5\u9519\u8bef\u4fe1\u606f<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u8fd0\u884c\u65f6\u51fa\u73b0\u9519\u8bef\uff0cPython\u4f1a\u5728\u7ec8\u7aef\u4e2d\u663e\u793a\u9519\u8bef\u4fe1\u606f\u3002\u6839\u636e\u9519\u8bef\u63d0\u793a\uff0c\u56de\u5230\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u4fee\u6539\u4ee3\u7801\uff0c\u786e\u4fdd\u8bed\u6cd5\u6b63\u786e\u4e14\u903b\u8f91\u5408\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ba1\u7406Python\u5305<\/strong><\/p>\n<\/p>\n<p><p>Termux\u4e2d\u7684Python\u652f\u6301\u4f7f\u7528<code>pip<\/code>\u8fdb\u884c\u5305\u7ba1\u7406\u3002\u8981\u5b89\u88c5\u7b2c\u4e09\u65b9Python\u5e93\uff0c\u4f8b\u5982<code>requests<\/code>\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\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\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6307\u5b9a\u7684Python\u5e93\uff0c\u4ee5\u4fbf\u5728\u811a\u672c\u4e2d\u4f7f\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u9700\u8981\u5728\u4e0d\u540c\u9879\u76ee\u4e2d\u4f7f\u7528\u4e0d\u540c\u7248\u672c\u7684\u5e93\uff0c\u53ef\u4ee5\u521b\u5efaPython\u865a\u62df\u73af\u5883\u3002\u9996\u5148\uff0c\u786e\u4fdd\u5b89\u88c5\u4e86<code>virtualenv<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install virtualenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u521b\u5efa\u5e76\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">virtualenv myenv<\/p>\n<p>source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u865a\u62df\u73af\u5883\u4e2d\uff0c\u53ef\u4ee5\u72ec\u7acb\u5b89\u88c5\u548c\u7ba1\u7406\u6240\u9700\u7684Python\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u63d0\u9ad8PYTHON\u811a\u672c\u6027\u80fd\u548c\u517c\u5bb9\u6027<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u63d0\u9ad8Python\u811a\u672c\u7684\u6027\u80fd\u548c\u517c\u5bb9\u6027\uff0c\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f18\u5316\u4ee3\u7801\u6027\u80fd<\/strong><\/p>\n<\/p>\n<p><p>\u5b9a\u671f\u5ba1\u67e5\u548c\u91cd\u6784\u4ee3\u7801\uff0c\u786e\u4fdd\u4f7f\u7528\u9ad8\u6548\u7684\u7b97\u6cd5\u548c\u6570\u636e\u7ed3\u6784\uff0c\u4ee5\u63d0\u9ad8\u811a\u672c\u7684\u6267\u884c\u6548\u7387\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u517c\u5bb9\u6027\u6d4b\u8bd5<\/strong><\/p>\n<\/p>\n<p><p>\u786e\u4fddPython\u4ee3\u7801\u5728\u4e0d\u540c\u7248\u672c\u7684Python\u89e3\u91ca\u5668\u4e0b\u90fd\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u7279\u522b\u662f\u5728\u4f7f\u7528\u65b0\u7279\u6027\u6216\u7b2c\u4e09\u65b9\u5e93\u65f6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u7248\u672c\u63a7\u5236<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528Git\u7b49\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u7ba1\u7406\u4ee3\u7801\u53d8\u5316\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u65f6\u56de\u6eda\u81f3\u4ee5\u524d\u7684\u7248\u672c\uff0c\u6216\u5728\u4e0d\u540c\u8bbe\u5907\u95f4\u540c\u6b65\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5728Termux\u4e2d\u8f7b\u677e\u8fd0\u884c\u548c\u7ba1\u7406Python\u6587\u4ef6\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u811a\u672c\u7ec3\u4e60\uff0c\u8fd8\u662f\u590d\u6742\u7684\u9879\u76ee\u5f00\u53d1\uff0cTermux\u90fd\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f3a\u5927\u4e14\u4fbf\u643a\u7684\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Termux\u4e2d\u5b89\u88c5Python\u73af\u5883\uff1f<\/strong><br \/>\u5728Termux\u4e2d\uff0c\u5b89\u88c5Python\u73af\u5883\u975e\u5e38\u7b80\u5355\u3002\u60a8\u53ea\u9700\u6253\u5f00Termux\u5e94\u7528\u5e76\u8f93\u5165\u547d\u4ee4<code>pkg install python<\/code>\u3002\u8fd9\u5c06\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u6765\u542f\u52a8Python\u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Termux\u4e2d\u521b\u5efa\u548c\u7f16\u8f91Python\u6587\u4ef6\uff1f<\/strong><br \/>\u5728Termux\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6765\u521b\u5efa\u548c\u7f16\u8f91Python\u6587\u4ef6\u3002\u5e38\u7528\u7684\u7f16\u8f91\u5668\u6709<code>nano<\/code>\u548c<code>vim<\/code>\u3002\u4f8b\u5982\uff0c\u8981\u4f7f\u7528<code>nano<\/code>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>script.py<\/code>\u7684\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165\u547d\u4ee4<code>nano script.py<\/code>\u3002\u5728\u7f16\u8f91\u5668\u4e2d\u8f93\u5165\u60a8\u7684Python\u4ee3\u7801\uff0c\u5b8c\u6210\u540e\u6309<code>CTRL + X<\/code>\uff0c\u7136\u540e\u9009\u62e9\u4fdd\u5b58\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Termux\u4e2d\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u4e00\u65e6\u60a8\u521b\u5efa\u4e86Python\u6587\u4ef6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165\u547d\u4ee4<code>python script.py<\/code>\u6765\u8fd0\u884c\u5b83\u3002\u786e\u4fdd\u5728\u6267\u884c\u6b64\u547d\u4ee4\u4e4b\u524d\uff0c\u60a8\u5df2\u7ecf\u5728\u7ec8\u7aef\u4e2d\u5bfc\u822a\u5230\u5b58\u50a8\u8be5Python\u6587\u4ef6\u7684\u76ee\u5f55\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u7684\u811a\u672c\u5c06\u5f00\u59cb\u6267\u884c\uff0c\u5e76\u5728\u7ec8\u7aef\u4e2d\u663e\u793a\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Termux\u4e2d\u8fd0\u884cPython\u6587\u4ef6\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u5b89\u88c5Termux\u548cPython\u3001\u521b\u5efaPython\u6587\u4ef6\u3001\u4f7f\u7528\u7ec8\u7aef [&hellip;]","protected":false},"author":3,"featured_media":990897,"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\/990885"}],"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=990885"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/990885\/revisions"}],"predecessor-version":[{"id":990900,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/990885\/revisions\/990900"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/990897"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=990885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=990885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=990885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}