您的位置:首页 > 编程语言 > Python开发

python paramiko模块的安装使用

2014-05-14 21:43 691 查看
一、安装pycryto模块

我的机器安装的是python27

安装pycryto,安装了easy_install工具,在cmd窗口上执行命令:

C:\Python27\Scripts\easy_install.exe pycrypto

在执行安装时,出现下面的错误,

error: Setup script exited with error: Unable to find vcvarsall.bat

网上找到了下面解决方法(http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat):

While running setup.py for package installations Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path in VS90COMNTOOLS environment
variable before calling setup.py.

If you have Visual Studio 2010 installed, execute

SET VS90COMNTOOLS=%VS100COMNTOOLS%

or with Visual Studio 2012 installed (Visual Studio Version 11)

SET VS90COMNTOOLS=%VS110COMNTOOLS%

or with Visual Studio 2013 installed (Visual Studio Version 12)

SET VS90COMNTOOLS=%VS120COMNTOOLS%

由于我机器上了安装了vs2010

在命令行上执行SET VS90COMNTOOLS=%VS100COMNTOOLS%,然后再执行C:\Python27\Scripts\easy_install.exe pycrypto,ok。

二、安装paramiko

执行命令

C:\Python27\Scripts\easy_install.exe paramiko,ok。

三 、在IDLE上面使用paramiko模块

>>> import paramiko

>>> hostname="192.168.1.129"

>>> username="zz"

>>> password="xxxxxxx"

>>> paramiko.util.log_to_file("C:\paramiko.log")

>>> s = paramiko.SSHClient()

>>> s.set_missing_host_key_policy(paramiko.AutoAddPolicy())

>>> s.connect(hostname=hostname, username=username, password=password)

>>> stdin,stdout,stderr=s.exec_command('whoami')

>>> print stdout.read()

root

>>>s.close()

相关网址

http://pythonpeixun.blog.51cto.com/7195558/1213929系统运维工程师的法宝:python paramiko

http://www.paramiko.org/



http://www.firefoxbug.net/?p=1698python paramiko模块安装和使用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: