linux python 2.6安装 paramiko

1、安装

  安装paramiko有两个先决条件,python和另外一个名为PyCrypto的模块。

  通常安装标准的python模块,只需要在模块的根目录下运行:

python setup.py build

python setup.py install

备注:安装前先检查是否安装gcc(yum -y install gcc)

    1. PyCrypto安装

       以下安装的2.6 发现后面有问题 可以直接安装2.6.1

https://www.dlitz.net/software/pycrypto/ 下载地址

 

wget http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz

tar -zxvf pycrypto-2.6.tar.gz

cd pycrypto-2.6/

python setup.py build && python setup.py install

  测试:

python>> import Crypto

(编译时报错:error: command 'gcc' failed with exit status 1;这是因为缺少python-dev的软件包,所yum -y install python-devel)

1.2 paramiko安装

安装paramiko:https://pypi.org/project/paramiko/1.7.7.1/#files

下载后解压,

unzip  paramiko-1.7.7.1.zip

cd paramiko-1.7.7.1

python setup.py build && python setup.py install

  测试:

python>> import paramiko

Traceback (most recent call last):

  File "", line 1, in

  File "paramiko/__init__.py", line 69, in

    from transport import SecurityOptions, Transport

  File "paramiko/transport.py", line 32, in

    from paramiko import util

  File "paramiko/util.py", line 32, in

    from paramiko.common import *

  File "paramiko/common.py", line 98, in

    from Crypto import Random

  File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29, in

    from Crypto.Random import _UserFriendlyRNG

  File "/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in

    from Crypto.Random.Fortuna import FortunaAccumulator

  File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in

    import FortunaGenerator

  File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, in

    from Crypto.Util.number import ceil_shift, exact_log2, exact_div

  File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in

    if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:

AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'

 

  把if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:

  注释了

#if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:

)

 

如果crypto是安装的2.6.1的话 下面内容应该不需要了

 

继续报错

>> import paramiko

Traceback (most recent call last):

  File "", line 1, in

  File "paramiko/__init__.py", line 69, in

    from transport import SecurityOptions, Transport

  File "paramiko/transport.py", line 32, in

    from paramiko import util

  File "paramiko/util.py", line 32, in

    from paramiko.common import *

  File "paramiko/common.py", line 98, in

    from Crypto import Random

  File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 28, in

    from Crypto.Random import OSRNG

ImportError: cannot import name OSRNG

 

 

 

Linux下python2.7安装pip

https://www.cnblogs.com/smail-bao/p/6483759.html

首先下载并安装setuptools:

wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py

sudo python ez_setup.py --insecure

再到python官网下载pip安装包,解压到某个位置,我这里下载的是8.0.0版本,然后就可以安装了:

wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
tar -xf pip-9.0.1.tar.gz
cd pip-8.0.0

sudo python setup.py install
ln -s /usr/local/python27/bin/pip /usr/bin/pip

 

 

pip 查看已经安装包的命令以及版本

pip freeze

 

删除一个依赖包

pip uninstall xxx 

Eg :pip uninstall pycrypto

删除 替换一个一个高级版本2.6.1

参考:

https://blog.csdn.net/winterto1990/article/details/47455405

 

Crypto 2.6.1版本

https://www.dlitz.net/software/pycrypto/

重新装一下:

 

 

参考:

https://www.linuxidc.com/Linux/2017-01/139973.htm (主要)

 

https://blog.csdn.net/zyz511919766/article/details/18355795

 

https://www.programering.com/q/MDNxIjNwATY.html (升级 crypto的版本)

 

linux python 2.6安装 paramiko_第1张图片

 

 

你可能感兴趣的:(python)