歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

RHEL6下安裝Python相關的paramiko

最近學習了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模塊已經正確安裝,可以正常使用了,關於該模塊的使用方法以後再續寫相關文檔!

Copyright © Linux教程網 All Rights Reserved