{"id":790,"date":"2025-05-22T08:00:09","date_gmt":"2025-05-22T00:00:09","guid":{"rendered":"https:\/\/www.zhoubin.asia\/?p=790"},"modified":"2025-05-21T12:09:43","modified_gmt":"2025-05-21T04:09:43","slug":"termux_python","status":"publish","type":"post","link":"https:\/\/www.zhoubin.asia\/index.php\/2025\/05\/22\/termux_python\/","title":{"rendered":"\u5982\u4f55\u5728 Android \u4e2d\u5229\u7528termux\u914d\u7f6e\u5e76\u4f7f\u7528 Linux \u73af\u5883\u4ee5\u53ca Python"},"content":{"rendered":"<p>\u6211\u4eca\u5929\u7684\u65b9\u6848\u4e3b\u8981\u662f\u901a\u8fc7\u4f7f\u7528 <strong>Termux<\/strong> app \u6765\u5b9e\u73b0\u5728 Android \u7aef\u90e8\u7f72 Linux \u73af\u5883\u548c Python \u73af\u5883\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e2a\u57fa\u4e8e VLM \u7684\u4f7f\u7528\u4f8b\u5b50\uff08\u5c06\u4e0d\u6d89\u53ca VLM \u672c\u8eab\uff09\uff0c\u805a\u7126\u4e8e\u73af\u5883\u7684\u642d\u5efa\uff0c\u5305\u62ec Termux \u7684\u5b89\u88c5\u3001Python \u73af\u5883\u8bbe\u7f6e\uff0c\u4ee5\u53ca\u5728 Python \u865a\u62df\u73af\u5883\u4e2d\u90e8\u7f72 Gradio \u7f51\u9875\u670d\u52a1\u7684\u5168\u8fc7\u7a0b\u3002<\/p>\n<h2>1. \u5b89\u88c5 Termux<\/h2>\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u7f51\u7edc\u4e0b\u8f7d Termux \u7684 APK \u6587\u4ef6\u5e76\u76f4\u63a5\u5b89\u88c5\u3002<\/p>\n<p>\u5982\u679c\u4f60\u7684 Android \u7248\u672c\u8f83\u4f4e\uff08\u5982\u67d0\u4e9b\u5de5\u4e1a Android \u7cfb\u7edf\uff09\uff0cTermux \u5206\u53d1\u683c\u5f0f\u4e3a xapk\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u5b89\u88c5\uff1a<\/p>\n<ul>\n<li>\u5c06 <code>.xapk<\/code> \u91cd\u547d\u540d\u4e3a <code>.zip<\/code> \u5e76\u89e3\u538b<\/li>\n<li>\u4f7f\u7528 <code>adb install-multiple<\/code> \u547d\u4ee4\u5b89\u88c5\uff1a<\/li>\n<\/ul>\n<pre><code>adb install-multiple com.termux.apk config.arm64_v8a.apk config.en.apk config.mdpi.apk config.zh.apk<\/code><\/pre>\n<h2>2. \u5b89\u88c5 Python 3.10<\/h2>\n<p>Termux \u9ed8\u8ba4\u4f7f\u7528 Python 3.12\uff0c\u4f46\u56e0\u7279\u6b8a\u539f\u56e0\uff0c\u6211\u9700\u8981 Python 3.10\uff0c\u5b89\u88c5\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<pre><code>pkg update &amp;&amp; pkg upgrade\r\npkg uninstall python\r\npkg install tur-repo\r\npkg update\r\npkg install python3.10\r\nln -sf \/data\/data\/com.termux\/files\/usr\/bin\/python3.10 $PREFIX\/bin\/python3\r\nln -sf \/data\/data\/com.termux\/files\/usr\/bin\/python3.10 $PREFIX\/bin\/python<\/code><\/pre>\n<h2>3. \u6784\u5efa NumPy<\/h2>\n<p>NumPy \u65e0\u6cd5\u901a\u8fc7\u76f4\u63a5 pip \u5b89\u88c5 wheel \u6587\u4ef6\u7684\u65b9\u5f0f\u5b8c\u6210\uff0c\u56e0\u6b64\u9700\u901a\u8fc7\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\uff1a<\/p>\n<pre><code>pkg install lfortran\r\nexport FC=lfortran\r\npip install setuptools==59.8.0\r\npkg install libexecinfo build-essential openblas llvm libllvm\r\nMATHLIB=\"m\" pip install numpy==1.25.2<\/code><\/pre>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u4e0d\u8981\u5728 Python 3.10 \u73af\u5883\u4e0b\u5b89\u88c5 numpy2, \u6240\u4ee5\u6211\u8fd9\u8fb9\u6307\u5b9a\u4e86\u7248\u672c1.25.2\uff1b \u5982\u679c\u4f60\u662fpython 3.12 \u5219\u53ef\u4ee5\u5b89\u88c5numpy2\u3002<\/p>\n<h2>4. \u5b89\u88c5 Gradio<\/h2>\n<p>Gradio \u4f9d\u8d56\u591a\u4e2a\u7f16\u8bd1\u5e93\uff0c\u540c\u65f6 <code>Pillow<\/code> \u8fd8\u4f9d\u8d56 JPEG \u652f\u6301\u3002\u4ee5\u4e0b\u662f\u51c6\u5907\u5de5\u4f5c\uff1a<\/p>\n<pre><code>pkg update &amp;&amp; pkg upgrade\r\npkg install python\r\npkg install clang make libffi libjpeg-turbo rust<\/code><\/pre>\n<h2>5. \u5173\u4e8e\u56fd\u5185\u7f51\u7edc\u4e0b\u8f7d\u95ee\u9898<\/h2>\n<p>\u5728\u56fd\u5185\u73af\u5883\u4e2d\u90e8\u7f72 Gradio \u65f6\uff0c\u53ef\u80fd\u4f1a\u56e0\u4e0b\u8f7d Huggingface \u6240\u4f9d\u8d56\u7684 <code>frpc<\/code> \u6587\u4ef6\u5931\u8d25\u800c\u51fa\u9519\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\u4e3a\uff1a\u624b\u52a8\u4e0b\u8f7d\u8be5\u6587\u4ef6\u5e76\u653e\u7f6e\u5230\u76ee\u5f55 <code>.cache\/huggingface\/gradio\/frpc<\/code> \u4e2d\u3002<\/p>\n<p>\u4f7f\u7528 Gradio \u65f6\u9875\u9762\u4f1a\u63d0\u793a\u7f3a\u5931\u8be5\u6587\u4ef6\u5e76\u63d0\u4f9b\u4e0b\u8f7d\u94fe\u63a5\uff0c\u53ef\u6839\u636e\u63d0\u793a\u8fdb\u884c\u5904\u7406\uff08\u53ef\u80fd\u9700\u8981\u68af\u5b50\uff09\u3002<\/p>\n<p>\u81f3\u6b64\uff0c\u4e00\u4e2a\u53ef\u7528\u7684 Android + Linux + Python + Gradio \u73af\u5883\u5c31\u914d\u7f6e\u5b8c\u6210\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eca\u5929\u7684\u65b9\u6848\u4e3b\u8981\u662f\u901a\u8fc7\u4f7f\u7528 Termux app \u6765\u5b9e\u73b0\u5728 Android \u7aef\u90e8\u7f72 Linux \u73af\u5883\u548c Pyt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-790","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts\/790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/comments?post=790"}],"version-history":[{"count":1,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts\/790\/revisions"}],"predecessor-version":[{"id":791,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/posts\/790\/revisions\/791"}],"wp:attachment":[{"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/media?parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/categories?post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhoubin.asia\/index.php\/wp-json\/wp\/v2\/tags?post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}