0

我使用以下方法安装了 paramiko 1-7-5:

wget http://www.lag.net/paramiko/download/paramiko-1.7.5.zip
unzip paramiko-1.7.5.zip
cd paramiko-1.7.5
python setup.py install

在 python 脚本中使用 import paramiko 时出现以下错误:

Traceback (most recent call last):
File "psql.py", line 8, in <module>
import paramiko
File "/home/nish/.pythonbrew/pythons/Python-3.3.0/lib/python3.3/site-packages/paramiko-1.7.5-py3.3.egg/paramiko/__init__.py", line 69, in <module>
from transport import randpool, SecurityOptions, Transport
ImportError: No module named 'transport'

我试图找到类似的帖子,但找不到答案。我该如何解决这个错误。

以下是我正在使用的 Python 脚本:

#! /usr/bin/python

import shlex
import os
import subprocess
import string
import random
import paramiko


cmd = 'ssh -i FILE.pem root@EC2instance
args = shlex.split(cmd)
print("\n")
print (args)
p=subprocess.Popen(args)
p.wait()


cmd = 'psql'
print("\n")
print(cmd)
p=subprocess.Popen(cmd)
p.wait()

以下是我正在改变的错误

from transport import randpool, SecurityOptions, Transport

from paramiko.transport import randpool, SecurityOptions, Transport

或者

from paramiko.transport import SecurityOptions, Transport

Traceback (most recent call last):
File "psql.py", line 8, in <module>
import paramiko
File "/home/nish/.pythonbrew/pythons/Python-3.3.0/lib/python3.3/site-packages/paramiko-1.7.5-py3.3.egg/paramiko/__init__.py", line 69, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/home/nish/.pythonbrew/pythons/Python-3.3.0/lib/python3.3/site-packages/paramiko-1.7.5-py3.3.egg/paramiko/transport.py", line 364
out = '<paramiko.Transport at %s' % hex(long(id(self)) & 0xffffffffL)
                                                                   ^
SyntaxError: invalid syntax
4

0 回答 0