Python中有些模块很难安装,摸索到一些模块的安装方法,记录一下以防以后要用。本文待续,以后安装其他模块再补充…………
python3安装pycrypto
对于kali linux,python2默认安装了pycrypto,但是对于python3并没有。首先安装python3的一些依赖环境:
apt-get install python3-dev;
在kali linux下使用命令pip会默认使用python2的pip。
按照网上的说法,运行命令:
pip3 install pycrypto;
发现返回找不到命令pip3,使用命令:
python3 -m pip install pycrypto
显示找不到模块pip,可知linux下默认并没有安装python3的pip模块,猜测python3可能安装了easy_install模块,调用easy_install模块安装pip运行命令:
python3 -m easy_install pip
安装完pip,运行命令:
python3 -m pip install pycrypto
成功在python3里安装模块pycrypto
安装pillow(不知道是否可行,未完,待续……)
pip install -I --no-cache-dir -v Pillow
kali linux64位安装gmpy2
pip install gmpy2
报错,猜测为环境问题,执行命令:
apt-get install gcc python-dev
后,继续
pip install gmpy2
仍然报错,查看报错信息:
In file included from src/gmpy2.c:426:0:
src/gmpy.h:252:20: fatal error: mpfr.h: 没有那个文件或目录
# include "mpfr.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-smq1ryxv/gmpy2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-491iqg3a-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-smq1ryxv/gmpy2/
显示缺少mfpr.h文件,搜索后得到解决方法为:下载最新的mpfr的压缩包安装:
下载地址:mpfr
我下载的版本是mpfr-3.1.5
解压后进入目录:
cd mpfr-3.1.5
./configure
make
make check
VERBOSE=1 make check
make install
无报错,安装完成
再次执行:
pip install gmpy2
出现新报错信息:
In file included from src/gmpy2.c:426:0:
src/gmpy.h:261:19: fatal error: mpc.h: 没有那个文件或目录
# include "mpc.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-xnmfmila/gmpy2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-qvbp_577-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-xnmfmila/gmpy2/
由报错信息知出现mpc.h缺失,下载安装mpc压缩包,这里我下载的是mpc-1.0.3
cd mpc-1.0.3
./configure
make
make install
无报错信息,成功安装
之后再安装gmpy2
pip install gmpy2
无特殊情况的话,最终应该会显示成功安装。