• centos7 python2.7下安装paramiko模块


    1.资源准备

    (1)下载源码paramiko安装包

    (2)下载paramiko安装包的依赖包:pycrypto安装包和gcc包  (gcc包用yum安装)

    2.安装

    (1)gcc包安装

    yum -y install gcc

    (2)pycrypto包安装(版本pycrypto-2.6.1)

    将源码安装包放到当前家目录下

    tar xvzf pycrypto-2.6.1.tar.gz

    cd pycrypto-2.6.1.tar.gz

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

    ******报错******

    src/MD2.c:31:20: 致命错误:Python.h:没有那个文件或目录
     #include "Python.h"
                        ^
    编译中断。
    error: command 'gcc' failed with exit status 1

    提示缺少Python.h文件 

    解决办法:yum install python-devel.x86_64

    提示“gcc" failed with exit status 1

    解决办法:yum -y install python-devel

    然后重新安装pycrypto包

    (3)安装paramiko包

    将源码安装包放到当前家目录下

    tar xvzf paramiko-2.4.0.tar.gz

    cd paramiko-2.4.0.tar.gz

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

    提示错误:error: Installed distribution cffi 0.8.6 conflicts with requirement cffi>=1.4.1
    下载安装cffi :https://pypi.python.org/pypi/cffi/
    ar -xzvf cffi-1.8.2.tar.gz
    cd cffi_1.8.2

    python setup.py build

    提示错误:fatal error: ffi.h: No such file or directory

    解决办法:yum install libffi-devel
                    python setup.py install

    提示错误:fatal error: openssl/opensslv.h: No such file or directory
    解决办法  yum install openssl-devel
                    python setup.py install

    然后再安装 paramiko

    如果安装遇到error in cryptography setup command: Invalid environment marker: python_version < '3'
    解决办法:sudo pip install --upgrade setuptools
                     sudo yum install libffi-devel

    安装完后在python2.7中  import paramiko

    ******报错******

    >>> import paramiko
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "paramiko/__init__.py", line 22, in <module>
        from paramiko.transport import SecurityOptions, Transport
      File "paramiko/transport.py", line 38, in <module>
        from paramiko.auth_handler import AuthHandler
      File "paramiko/auth_handler.py", line 48, in <module>
        from paramiko.ssh_gss import GSSAuth, GSS_EXCEPTIONS
      File "paramiko/ssh_gss.py", line 54, in <module>
        GSS_EXCEPTIONS = (gssapi.GSSException,)
    AttributeError: 'module' object has no attribute 'GSSException'

    解决方法:yum install python-paramiko -y

  • 相关阅读:
    discuz方法赏析
    rpm安装软件(需管理员权限)
    php.ini修改php上传文件大小限制
    grep 基于关键字搜索
    网络排查的原则
    Sublime Text快捷键
    表格无边框,有内框,在table嵌套时,防止出现重复边线
    文件(图片)强制下载
    网络相关配置文件的位置
    ip,子网掩码,网关,DNS
  • 原文地址:https://www.cnblogs.com/weigege2015/p/8080082.html
Copyright © 2020-2023  润新知