2017-11-21 21 views
1

私はリモートSSHサーバに接続するためにWindows上にスクリプトを作成しました。私は正常にcryptographypynacl、そして最後にparamikoをインストールしました。WindowsにPythonの暗号をインストールする

スクリプトを実行すると、DLLの読み込みに失敗したというエラーが表示されます。エラーはlibsodiumに関連しているようですが、どのDLLがロードしようとしているのか正確に把握できません。より安全な側にいるだけで、私はpysodiumもインストールしました。ここで

はスクリプトです:

automate.py

import SSH 

connection = ssh("10.10.65.100", "gerrit2", "[email protected]") 
print("Calling OpenShell") 
connection.openShell() 
print("Calling sendShell") 
connection.sendShell("ls -l") 
print("Calling process") 
connection.process() 
print("Calling closeConnection") 
connection.closeConnection() 

SSH.py

import threading, paramiko 

class ssh: 
    shell = None 
    client = None 
    transport = None 

    def __init__(self, address, username, password): 
     print("Connecting to server on ip", str(address) + ".") 
     self.client = paramiko.client.SSHClient() 
     self.client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy()) 
     self.client.connect(address, username=username, password=password, look_for_keys=False) 
     self.transport = paramiko.Transport((address, 22)) 
     self.transport.connect(username=username, password=password) 

     thread = threading.Thread(target=self.process) 
     thread.daemon = True 
     thread.start() 

    def closeConnection(self): 
     if(self.client != None): 
      self.client.close() 
      self.transport.close() 

    def openShell(self): 
     self.shell = self.client.invoke_shell() 

    def sendShell(self, command): 
     if(self.shell): 
      self.shell.send(command + "\n") 
     else: 
      print("Shell not opened.") 

    def process(self): 
     global connection 
     while True: 
      # Print data when available 
      if self.shell != None and self.shell.recv_ready(): 
       alldata = self.shell.recv(1024) 
       while self.shell.recv_ready(): 
        alldata += self.shell.recv(1024) 
       strdata = str(alldata, "utf8") 
       strdata.replace('\r', '') 
       print(strdata, end = "") 
       if(strdata.endswith("$ ")): 
        print("\n$ ", end = "") 

そして、ここでエラーです:グーグルでの多くの後

> python automate.py 

Traceback (most recent call last): 
    File "automate.py", line 1, in <module> 
    import SSH 
    File "D:\Automate\SSH_Paramiko\SSH.py", line 1, in <module> 
    import threading, paramiko 
    File "D:\Users\prashant-gu\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko-2.4.0-py3.7.egg\paramiko\__init__.py", line 22, in <module> 
    File "D:\Users\prashant-gu\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko-2.4.0-py3.7.egg\paramiko\transport.py", line 57, in <module> 
    File "D:\Users\prashant-gu\AppData\Local\Programs\Python\Python37\lib\site-packages\paramiko-2.4.0-py3.7.egg\paramiko\ed25519key.py", line 22, in <module> 
    File "D:\Users\prashant-gu\AppData\Local\Programs\Python\Python37\lib\site-packages\nacl\signing.py", line 19, in <module> 
    import nacl.bindings 
    File "D:\Users\prashant-gu\AppData\Local\Programs\Python\Python37\lib\site-packages\nacl\bindings\__init__.py", line 17, in <module> 
    from nacl.bindings.crypto_box import (
    File "D:\Users\prashant-gu\AppData\Local\Programs\Python\Python37\lib\site-packages\nacl\bindings\crypto_box.py", line 18, in <module> 
    from nacl._sodium import ffi, lib 
ImportError: DLL load failed: The specified module could not be found. 
+0

* pynacl *がインストールされていないようです。拡張モジュールの1つ(またはその* .dll *の依存関係の一部)が見つかりません。単に 'import paramiko'によって問題を再現できるはずです。ところで、あなたのパスに* Python37 *はありますか? – CristiFati

+0

@CristiFati:私は 'どこにpython'して、このパス' D:\ Users \ prashant-gu \ AppData \ Local \ Programs \ Python \ Python37 \ python.exe'を受け取った –

+0

@CristiFati:あなたが私に与えた手がかりをありがとう。それは多大な努力を要しましたが、最終的に問題は解決しました。 –

答えて

0

が、私は最終的にthisにつまずきました。私は私の以前のpynaclのインストールをアンインストールし、会話で述べたように、https://github.com/lmctv/pynacl/archive/v1.2.a0.reorder.zipからzip形式のソースをダウンロードし、https://github.com/jedisct1/libsodium/releases/download/1.0.15/libsodium-1.0.15.tar.gzからダウンロードlibsodiumは、D:\Users\prashant-gu\Downloads\libsodium-1.0.15\bin\x64\Release\v140\dynamicLIB環境変数を設定し、最終的に

pip install .

を使用して、このダウンロードしたソースpynaclフォームを設置それはうまく動作します。

paramikoのインストール中に、私はまた、https://ci.cryptography.io/job/cryptography-support-jobs/job/openssl-release-1.1/からOpenSSLをダウンロードして起こる、とのセットが正常にparamikoの依存関係であることを起こるcryptographyパッケージをインストールするためにD:\Users\prashant-gu\Downloads\openssl-1.1.0g-2015-x86_64\openssl-win64-2015\includeに環境変数が含まれています。

関連する問題