栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

华为nova4手机Termux安装Linux教程

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

华为nova4手机Termux安装Linux教程

手机配置:华为nova4,手机 上Termux安装Linux,跑scrapy. 如果你按照我的步骤一定也可以成功在手机上搭建一个Linux系统,且手机不需要root权限。

文章目录
  • 前言
  • 一、手机上安装Termux
  • 二、Termux换清华源
    • 1.换清华源
      • 1.编辑 $PREFIX/etc/apt/sources.list
      • 2.编辑 $PREFIX/etc/apt/sources.list.d/science.list
      • 3.编辑 $PREFIX/etc/apt/sources.list.d/game.list
    • 2.手机上的proot-distro安装
      • 1.列出可安装系统
      • 2.选择安装ubuntu
      • 3.报错Operation not permitted
      • 4.手机上正常使用ubuntu
  • 三、安装python
    • 1. 安装python3.9
    • 2. 安装pip
  • 四、pip安装scrapy,bottle
    • 1.爬虫
    • 2.静态页面模板
  • 总结
    • 1. 换安装源,外部源可能无法访问
    • 2. proot-distro list 能列出安装的系统
    • 3. 报错:error while loading shared libraries:libtinfo.so.6:cannot stat shared object: Operation not permitted
    • 4. 报错:Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 9707(apt-get)
    • 5. 报错:No module name 'distutils.cmd'


前言

如果你有强劲的处理能力的电脑,可以跳过。因为在AWS的机器上免费的机器只有1G内存,30G免费空间。它跑python的scrapy程序太慢,生成html效率太低,所以EC2它不适合这些功能。手机上的性能和空间都完胜EC2,所以我在手机上生成好静态文件后,直接用scp命令远程复制到EC2上。

一、手机上安装Termux

手机之前上就安装有AnLinux和Termux,只用来远程连接一下linux。并未将它作为程序处理。AnLinux和Termux的安装不在文章之列。

二、Termux换清华源 1.换清华源

正常操作是无法从Termux提供的源下载的,要换成国内源。
根据清华源的操作一步步进行。
可以使用图形界面或手动修改源。参考官方帮助文档 https://mirrors.tuna.tsinghua.edu.cn/help/termux/
我使用手动修改,打开termux:
手动修改
可以先安装个vim,用vim编辑器

1.编辑 $PREFIX/etc/apt/sources.list

修改为如下内容

#The termux repository mirror from TUNA:
deb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main
2.编辑 $PREFIX/etc/apt/sources.list.d/science.list

修改为如下内容

# The termux repository mirror from TUNA:
deb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable
3.编辑 $PREFIX/etc/apt/sources.list.d/game.list

修改为如下内容

# The termux repository mirror from TUNA:
deb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable

请使用内置或安装在 Termux 里的文本编辑器,例如 vi / vim / nano 等,不要使用 RE 管理器等其他具有 ROOT 权限的外部 APP 来修改 Termux 的文件

改好之后刷新下源

apt updage
2.手机上的proot-distro安装

前面一步如果不换源,可能这一步就会失败。

1.列出可安装系统
pkg install proot wget -y
pkg installl proot-distro

如下列出了可以安装的系统,只能安装它列出来的:

proot-distro list

2.选择安装ubuntu
proot-distro ubuntu

如下已经提示安装成功,可以登录。

3.报错Operation not permitted

出现了报错:error while loading shared libraries:libtinfo.so.6:cannot stat shared object: Operation not permitted
解决办法:设置环境变量PROOT_NO_SEECOMP=1

export PROOT_NO_SEECOMP=1

重新登录成功:

proot-distro login ubuntu

4.手机上正常使用ubuntu

登录后显示root@localhost:
此时已经进入ubuntu
常用命令正常2
到这里已经可以正常使用ubuntu了。

三、安装python 1. 安装python3.9
apt-get install python3

如下正在安装

但是出现了一个问题:选择地区和时区
地区我选择了6.Asia


出现的城市和地区里没有China啊。有Hong_Kong.
此时我应该退出选择,后面的时区我也选择退出。

退出后我重新安装

apt-get install python3

报错:Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 9707(apt-get)
apt-get被hold住了,我用kill掉进程。


后面提示用dpkg --configure -a:

dpkg --configure -a

退出ubuntu重新登录,再重新安装python就可以了。
再使用python 指向python3
python3.9 ,优先级1.

update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1


已经安装好pythonu并做好指向

2. 安装pip

安装好python后,pip没有

官网安装Pip方法https://pip.pypa.io/en/stable/installation/
下载get-pip.py到本地

 wget https://bootstrap.pypa.io/get-pip.py

安装Pip

 python get-pip.py

报错:No module name 'distutils.cmd’

解决:

apt-get install python3-distutils

再次运行pip安装命令

python get-pip.py
pip -V

四、pip安装scrapy,bottle 1.爬虫
pip install scrapy 
2.静态页面模板
 pip install bottle   

最终对比
手机性能完全胜过EC2, 1秒钟随便生成5000+静态页面没问题

总结

以上就是今天要讲的内容,本文仅仅简单介绍手机上安装ubuntu系统并跑计算程序。主要有几点注意:

1. 换安装源,外部源可能无法访问 2. proot-distro list 能列出安装的系统 3. 报错:error while loading shared libraries:libtinfo.so.6:cannot stat shared object: Operation not permitted 4. 报错:Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 9707(apt-get) 5. 报错:No module name ‘distutils.cmd’
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/302875.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号