Recently, due to some requirements, I had to work on python, so I had to work on it over the weekend. to connect to the server and perform some server operations, install the Paramiko package. For more information, see # wiki/1514.html "target =" _ blank "> python, so we started this weekend. to connect to the server and perform some server operations, install this Paramiko package and directly
pip install paramiko
Result: an error is reported. The most important sentence is:
error: Unable to find vcvarsall.bat
Google circle. finally, find the simplest method. other installation. installing MinGW is too complicated. install the third-party version of PyCrypto because paramiko depends on PyCrypto. the above error is reported by him. install PyCrypto third-party edition
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 complete, install paramiko again. 2. modify nt. py to install the above steps and 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.exe c_command (m) out = stdout. readlines () # screen output for o in out: print (o) print ('% s \ tOK \ n' % (ip) ssh. close () failed t: print ('% s \ tError \ n' % (ip) if name = 'main ': cmd = ['find/home/admin/logs/-mtime + 3-name \'*. log. * \ '-exec rm-rf {}\; '] # List of commands you want to execute username = "admin" # username passwd = "password" # password threads = [] # multithreading ip = "127.0.0.1" print ("Begin .. .... ") a = threading. thread (target = ssh2, args = (ip, username, passwd, cmd). start () input ()
Running error.
ImportError: No module named 'winrandom'
Find the installation directory of python3.5
Lib\site-packages\Crypto\Random\OSRNG
The nt. py file
import winrandom
Change
from . import winrandom
Run OK again. very simple
The above describes how to install paramiko in python3.5 in windows. For more information, see other related articles in the first PHP community!