Home  >  Article  >  Backend Development  >  Detailed explanation of the steps to install paramiko under python3.5 in windows environment

Detailed explanation of the steps to install paramiko under python3.5 in windows environment

高洛峰
高洛峰Original
2017-03-26 16:23:055510browse

Recently, due to some needs, I wanted to work on python, so I worked on it over the weekend. To connect to the server and perform some server operations, I installed this Paramiko package and directly

pip install paramiko

the result. When reporting an error, the most critical sentence is:

error: Unable to find vcvarsall.bat

google it .Finally found the simplest method. Other installations vs. installing MinGW are too complicated. Install the PyCrypto third-party version because paramiko relies on PyCrypto, and the above error is caused by him. Install the PyCrypto third-party version

pip install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win_amd64.whl pycrypto


After the installation is completed, install paramiko again. 2. Modify nt.py and install the above steps, write a simple program to test

#-*- coding: utf-8 -*-#!/usr/bin/python import paramikoimport threadingdef ssh2(ip,username,passwd,cmd):
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(ip,22,username,passwd,timeout=5)        for m in cmd:
            stdin, stdout, stderr = ssh.exec_command(m)
            out = stdout.readlines()            #屏幕输出
            for o in out:
                print(o)
        print('%s\tOK\n'%(ip))
        ssh.close()    except :
        print('%s\tError\n'%(ip))if name=='main':
    cmd = ['find /home/admin/logs/ -mtime +3 -name \'*.log.*\' -exec rm -rf {} \;']#你要执行的命令列表
    username = "admin"  #用户名
    passwd = "password"    #密码
    threads = []   #多线程
    ip = "127.0.0.1"
    print("Begin......")
    a=threading.Thread(target=ssh2,args=(ip,username,passwd,cmd))
    a.start() 
    input()

and run it and report an error.

ImportError: No module named 'winrandom'


Find the nt.py file of

Lib\site-packages\Crypto\Random\OSRNG

in the installation directory of python3.5 and change

import winrandom

to

from . import winrandom

and run ok again. Very simple

The above is the detailed content of Detailed explanation of the steps to install paramiko under python3.5 in windows environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn