华为nova4手机Termux安装Linux教程

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

原创不易,如果文章对你有帮助,请帮忙点赞。
原创地址:https://blog.csdn.net/fddqfddq/article/details/120653531,转载请注明出处。
请访问我的网站

博呈网:https://www.liuchangwei.com/


前言

如果你有强劲的处理能力的电脑,可以跳过。因为在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’

原创不易,如果文章对你有帮助,请帮忙点赞。
原创地址:https://blog.csdn.net/fddqfddq/article/details/120653531,转载请注明出处。
请访问我的网站

博呈网:https://www.liuchangwei.com/

  • 2
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值