M2芯片MacBook Air安装pwn库失败,求助手动构建unicorn方法
在M2芯片MacBook Air上手动构建Unicorn并安装Pwn库
问题背景
使用2022款M2芯片MacBook Air、Python 3.10.6环境时,执行python3 -m pip install --upgrade pwn或直接安装pwntools,均会出现Unicorn wheel构建失败的错误,核心报错内容为:
error: [Errno 2] No such file or directory: '/private/var/folders/6d/85dtjcrj57173csw50tk8r300000gn/T/pip-install-o33_11sd/unicorn_530dd415f77a40418edfdec7c2d599f2/../../include/unicorn'
原因是PyPI暂无适配M系列芯片的预编译Unicorn包,需手动构建。
手动构建步骤
1. 准备编译环境
先安装Xcode命令行工具,执行:
xcode-select --install
若需要cmake,可通过Homebrew安装:
brew install cmake
2. 克隆Unicorn源码仓库
克隆官方源码仓库,建议指定稳定版本(以2.0.1为例):
git clone --branch 2.0.1 https://github.com/unicorn-engine/unicorn.git cd unicorn
3. 构建并安装Unicorn核心库
执行编译与系统安装命令:
make sudo make install
此操作会将Unicorn的头文件与库文件安装至系统默认路径(/usr/local/include、/usr/local/lib)。
4. 安装Python绑定
进入Python绑定目录,完成安装:
cd bindings/python python3 setup.py install
也可使用pip完成安装:
pip3 install .
5. 安装Pwn/Pwntools库
完成上述步骤后,执行原安装命令即可成功:
python3 -m pip install --upgrade pwn
或直接安装pwntools:
python3 -m pip install pwntools
内容的提问来源于stack exchange,提问作者Kolliden
相关产品推荐
相关产品推荐

