Termux安装mitmproxy记录
Liuxspro
编辑于 2023年06月22日 19:31

Termux 下安装 Mitmproxy


时间: 2023 年 6 月 22 日 当前 Python 版本: 3.11.4 当前 mitmproxy 版本: 9.0.1

代码块
Shell
自动换行
复制代码
pip install mitmproxy
复制成功

直接安装会卡在 cryptography 很久,然后报错。

把 cryptography 包先拎出来按安装好。

在 termux 上安装,最简单的方法是 apt install python-cryptography,官方的软件源中已经内置了这个包。但是官的软件源中的版本是最新版本(41.0.1),而 mitmproxy 9.0.1 版本依赖的是 38.0.4 版本。因此,还是需要编译安装这个包 🤣。

安装好 rust 等依赖后(rust cargo clang pkgconfig openssl好像有这些,termux里都装过了,分不清楚哪些是必要的了😂),使用这个命令安装 cryptography 38.0.4 版本:

代码块
Shell
自动换行
复制代码
export RUSTFLAGS=" -C lto=no" && export CARGO_BUILD_TARGET="$(rustc -vV | sed -n 's|host: ||p')" && pip install cryptography==38.0.4
复制成功

然后安装 mitmproxy

代码块
Shell
自动换行
复制代码
pip install mitmproxy
复制成功

[Cant install cryptography for python · Issue #9982 · termux/termux-packages (github.com)](https://github.com/termux/termux-packages/issues/9982#issuecomment-1369107679)


如果不想编译,可以试试我在 termux 上编译后导出的 whl 包,依次下载安装:

代码块
Shell
自动换行
复制代码
wget https://cdn.jsdelivr.net/gh/liuxsdev/Python-Wheels-for-Termux/Wheels/cryptography-38.0.4-cp311-cp311-linux_aarch64.whl
wget https://cdn.jsdelivr.net/gh/liuxsdev/Python-Wheels-for-Termux/Wheels/mitmproxy_wireguard-0.1.23-cp37-abi3-linux_aarch64.whl
wget https://cdn.jsdelivr.net/gh/liuxsdev/Python-Wheels-for-Termux/Wheels/ruamel.yaml.clib-0.2.7-cp311-cp311-linux_aarch64.whl

pip install cryptography-38.0.4-cp311-cp311-linux_aarch64.whl
pip install mitmproxy_wireguard-0.1.23-cp37-abi3-linux_aarch64.whl
pip install ruamel.yaml.clib-0.2.7-cp311-cp311-linux_aarch64.whl

pip install mitmproxy
复制成功