1、更換國內源
更換Termux清華大學源,加快軟件包下載速度.
export EDITOR=vi
apt edit-sources
將原來的#deb https://termux.org/packages/ stable main官方源替換為
deb http://mirrors.tuna.tsinghua.edu.cn/termux stable main
2、Termux ssh使用密碼登錄
1. 獲取用戶名:在termux輸入whoami
2. 重置密碼:在termux輸入passwd
3. 打開sshd服務之後用前兩步的用戶名和密碼登錄
1. 設置密碼:在termux輸入passwd
2. 打開sshd服務之後在其它終端執行: ssh [ip地址] -p 8022更改密碼(或者說設定初始密碼)
$ passwd
(若出現錯誤嘗試輸入:pkg install termux-auth)
後應該會顯示這樣(設置密碼的時候,輸入不顯示):
New password:
Retype new password:
New password was successfully set.
安裝openssh
pkg upgrade
pkg install openssh
開啟ssh並連接
在安卓上開啟ssh請執行這一句:
sshd
如果要關閉執行這一句:
pkill sshd
在電腦上(控制端)執行這個:hostname_or_ip替換成自己的手機IP,手機的ip--進入路由器管理界面查查看
ssh -p 8022 user@hostname_or_ip
Windows子系統kail:
PowerShell:
輸入你的密碼,就可以成功鏈接了。
--------------------------------------------------------------------------------------
3、安裝python3:
pkg install python
--------------------------------------------------------------------------------------
4、安裝jupyterlab:
pip install jupyterlab
///////////////////////////////////
Running setup.py install for pyzmq 卡住
錯誤顯示:
ERROR: Command errored out with exit status 1:
command: /data/data/com.termux/files/usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/data/data/com.termux/files/usr/tmp/pip-install-nsejlo_o/pyzmq/setup.py'"'"'; __file__='"'"'/data/data/com.termux/files/usr/tmp/pip-install-nsejlo_o/pyzmq/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\\r\\n'"'"', '"'"'\\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /data/data/com.termux/files/usr/tmp/pip-record-vvk03zy4/install-record.txt --single-version-externally-managed --compile --install-headers /data/data/com.termux/files/usr/include/python3.8/pyzmq
cwd: /data/data/com.termux/files/usr/tmp/pip-install-nsejlo_o/pyzmq/
解決方法:
按照下步驟:
---------------------檢查基本操作和命令:
pkg update
pkg install vim curl wget git unzip unrar(這幾項可以選自己沒有的安裝)
---------------------安裝依賴包
apt-get install libzmq
---------------------重新安裝一遍jupyter
///////////////////////////////////
JupyterLab遠程訪問配置方法:
需要用ipython命令生成秘鑰,啟動ipython:
ipython
執行命令生成秘鑰:
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:3aa19817cfd5:f4d46129439a2de28aaaa03606360add7ae36323'
產生jupyterlab配置文件:
jupyter lab --generate-config
修改配置文件:
vi /data/data/com.termux/files/home/.jupyter/jupyter_notebook_config.py
更改內容如下:(a開始編輯; :wq 保存退出)
複製代碼
# 將ip設置為*,意味允許任何IP訪問
c.NotebookApp.ip = '*'
# 這裡的密碼就是上邊我們生成的那一串
c.NotebookApp.password = 'sha1:3aa19817cfd5:f4d46129439a2de28aaaa03606360add7ae36323'
# 服務器上並沒有瀏覽器可以供Jupyter打開
c.NotebookApp.open_browser = False
# 監聽端口設置為8888或其他自己喜歡的端口
c.NotebookApp.port = 8888
# 允許遠程訪問
c.NotebookApp.allow_remote_access = True
複製代碼
接下來輸入jupyter lab啟動jupyter服務即可:
jupyter lab --allow-root
完成!
--------------------------------------------------------------------------------------
安裝了 Termux: API 的 .apk 包之後
pkg install termux-api
5、ssh遠程命令行讀取手機氣壓計數據
讀取手機氣壓計1次
氣壓傳感器名稱BMP280
$ termux-sensor -s BMP280 -n 1
{
"BMP280 Pressure": {
"values": [
1009.7200317382812,
0,
0
]
}
}
閱讀更多 學得很雜的一個人 的文章
關鍵字: 2019科技之光 源文件 PowerShell