本安装基于Ubuntu32位系统,系统已经按照python2.7 以及pip。
使用最简单的安装方法:
sudo pip install pwntools
但安装出现错误:
You must install the Python development headers!
$ apt-get install python-dev
转而去安装缺少的包:
apt-get install python-dev
又出现如下错误:
The following packages have unmet dependencies:
python2.7-dev : Depends: python2.7 (= 2.7.6-8) but 2.7.6-8ubuntu0.2 is to be installed
Depends: libpython2.7-dev (= 2.7.6-8) but it is not going to be installed
Depends: libpython2.7 (= 2.7.6-8) but 2.7.6-8ubuntu0.2 is to be installed
Depends: libexpat1-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
解决方案:通过aptitude工具
1、首先安装aptitude:
sudo apt-get install aptitude
2、通过aptitude安装python-dev:
sudo aptitude install python-dev
出现:
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libexpat1-dev [Not Installed]
2) libpython-dev [Not Installed]
3) libpython2.7-dev [Not Installed]
4) python-dev [Not Installed]
5) python2.7-dev [Not Installed]
Accept this solution? [Y/n/q/?] n
这里一定选n,然后:
The following actions will resolve these dependencies:
Downgrade the following packages:
1) libexpat1 [2.1.0-4ubuntu1.3 (now) -> 2.1.0-4ubuntu1 (trusty)]
2) libpython2.7 [2.7.6-8ubuntu0.2 (now) -> 2.7.6-8 (trusty)]
3) libpython2.7-minimal [2.7.6-8ubuntu0.2 (now) -> 2.7.6-8 (trusty)]
4) libpython2.7-stdlib [2.7.6-8ubuntu0.2 (now) -> 2.7.6-8 (trusty)]
5) python2.7 [2.7.6-8ubuntu0.2 (now) -> 2.7.6-8 (trusty)]
6) python2.7-minimal [2.7.6-8ubuntu0.2 (now) -> 2.7.6-8 (trusty)]
Accept this solution? [Y/n/q/?] y
这里一定选y,然后再遇到都选择y即可按照完毕!
然后执行下面的pip按照就ok了!然后再安装pwntools:
sudo pip install pwntools
如果再出现错误:
Cannot uninstall 'pyserial'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
在安装命令中添加–ignore-installed:
sudo pip install --ignore-installed pwntools
如果出现类似如下错误:
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-f8m_zq/statsmod
原因是安装工具包时需要抓取网页因而要处理 https,而处理 https 又依赖加解密算法(即 cryptography 包),而 cryptography 又依赖傅立叶变换的算法以及相应的编译环境。Ubuntu 默认没有安装 libffi-dev 和 libssl-dev,gcc 也不一定安装,而 目标安装包又没有将相关软件包记到依赖列表里,因此需要先手动安装:
sudo apt-get install libssl-dev libffi-dev python-dev build-essential libxml2-dev libxslt1-dev