RHEL6下安装python相关的par

发布时间:2019-09-12 08:00:21编辑:auto阅读(1561)

    2012年 07月 13日 星期五 20:42:01 CST
    最近学习了python,用到paramiko模块了,以下是安装文档(注:yum源原配置省略)
    注:此文档适用于RedHat 6 或者 CentOS 6
    1、以下是源码包安装方式:
    参考以下网站:
    http://www.lag.net/paramiko/
    https://www.dlitz.net/software/pycrypto/ 或者 http://pypi.python.org/pypi/pycrypto
    wget https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz -O /tmp/pycrypto-2.6.tar.gz
    wget http://www.lag.net/paramiko/download/paramiko-1.7.7.1.tar.gz -O /tmp/paramiko-1.7.7.1.tar.gz
    yum remove python-crypto python-paramiko -y
    cd /tmp && tar zxf /tmp/pycrypto-2.6.tar.gz && cd pycrypto-2.6
    python setup.py -q build && python setup.py -q install

    cd /tmp && tar zxf /tmp/paramiko-1.7.7.1.tar.gz
    cd paramiko-1.7.7.1 && python setup.py -q build && python setup.py -q install
    cd /tmp && rm -rf pycrypto-2.6 paramiko-1.7.7.1
    通过以下方式检查安装结果:包括检查模块版本
    [root@RHEL601 ~]# python
    Python 2.6.5 (r265:79063, Jul 14 2010, 11:36:23)
    [GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> dir (Crypto)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'Crypto' is not defined
    >>> import Crypto
    >>> dir (Crypto)
    ['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__revision__', '__version__', 'version_info']
    >>> Crypto.__version__
    '2.6'
    >>> import paramiko
    >>> dir (paramiko)
    ['AUTH_FAILED', 'AUTH_PARTIALLY_SUCCESSFUL', 'AUTH_SUCCESSFUL', 'Agent', 'AgentKey', 'AuthHandler', 'AuthenticationException', 'AutoAddPolicy', 'BadAuthenticationType', 'BadHostKeyException', 'BaseSFTP', 'BufferedFile', 'Channel', 'ChannelException', 'ChannelFile', 'DSSKey', 'HostKeys', 'InteractiveQuery', 'Message', 'MissingHostKeyPolicy', 'OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED', 'OPEN_FAILED_CONNECT_FAILED', 'OPEN_FAILED_RESOURCE_SHORTAGE', 'OPEN_FAILED_UNKNOWN_CHANNEL_TYPE', 'OPEN_SUCCEEDED', 'PKey', 'Packetizer', 'PasswordRequiredException', 'RSAKey', 'RejectPolicy', 'SFTP', 'SFTPAttributes', 'SFTPClient', 'SFTPError', 'SFTPFile', 'SFTPHandle', 'SFTPServer', 'SFTPServerInterface', 'SFTP_BAD_MESSAGE', 'SFTP_CONNECTION_LOST', 'SFTP_EOF', 'SFTP_FAILURE', 'SFTP_NO_CONNECTION', 'SFTP_NO_SUCH_FILE', 'SFTP_OK', 'SFTP_OP_UNSUPPORTED', 'SFTP_PERMISSION_DENIED', 'SSHClient', 'SSHConfig', 'SSHException', 'SecurityOptions', 'ServerInterface', 'SubsystemHandler', 'Transport', 'WarningPolicy', '__all__', '__author__', '__builtins__', '__date__', '__doc__', '__file__', '__license__', '__name__', '__package__', '__path__', '__version__', '__version_info__', 'agent', 'auth_handler', 'ber', 'buffered_pipe', 'channel', 'client', 'common', 'compress', 'config', 'dsskey', 'file', 'hostkeys', 'kex_gex', 'kex_group1', 'message', 'packet', 'pipe', 'pkey', 'primes', 'resource', 'rsakey', 'server', 'sftp', 'sftp_attr', 'sftp_client', 'sftp_file', 'sftp_handle', 'sftp_server', 'sftp_si', 'ssh_exception', 'sys', 'transport', 'util']
    >>> paramiko.__version__
    '1.7.7.1 (George)'
    >>>
    [root@RHEL601 ~]#
    以上结果表明安装成功!

    2、yum安装方式如下:
    以下是我的安装方式,只需要安装python-paramiko,python-crypto即可
    [root@RHEL601 ~]# yum install python-crypto python-paramiko -y
    Loaded plugins: rhnplugin
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package python-crypto.i686 0:2.0.1-22.el6 set to be updated
    ---> Package python-paramiko.noarch 0:1.7.5-2.1.el6 set to be updated
    --> Finished Dependency Resolution

    Dependencies Resolved

    =====================================================================================
     Package                 Arch           Version                 Repository      Size
    =====================================================================================
    Installing:
     python-crypto           i686           2.0.1-22.el6            Server         156 k
     python-paramiko         noarch         1.7.5-2.1.el6           Server         728 k

    Transaction Summary
    =====================================================================================
    Install       2 Package(s)
    Upgrade       0 Package(s)

    Total download size: 884 k
    Installed size: 8.1 M
    Downloading Packages:
    -------------------------------------------------------------------------------------
    Total                                                 81 MB/s | 884 kB     00:00    
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing     : python-crypto-2.0.1-22.el6.i686                               1/2
      Installing     : python-paramiko-1.7.5-2.1.el6.noarch                          2/2

    Installed:
      python-crypto.i686 0:2.0.1-22.el6      python-paramiko.noarch 0:1.7.5-2.1.el6    

    Complete!
    import测试如下:
    [root@RHEL601 ~]# python
    Python 2.6.5 (r265:79063, Jul 14 2010, 11:36:23)
    [GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import paramiko
    >>>
    没有报错,说明paramiko模块已经正确安装,可以正常使用了,关于该模块的使用方法以后再续写相关文档!

关键字