【发布时间】:2018-11-26 21:48:25
【问题描述】:
谁能告诉我我在以下代码中犯了什么错误,我正在尝试使用机器人框架运行 shell 命令,并且我已经使用以下命令安装了 sshlibrary 模块 - pip install robotframework-sshlibrary。但我仍然收到导入 SSHLibrary 失败的错误。我的操作系统是 Ubuntu14.04。
Deploy.robot
*** Settings ***
Library SSHLibrary
Resource configuration.txt
*** Variables ***
${OBR_HOST} 10.110.72.192
${OBR_USERNAME} root
${OBR_PASSWORD} password
*** Test Cases ***
Deploy OBR machine code
${output}= Execute Command /root/deploy.sh
log to console ${\n}${output}
*** Keywords ***
open_connection_and_login
Open Connection ${OBR_HOST}
Login ${OBR_USERNAME} ${OBR_PASSWORD}
执行日志
root@92:~# pybot ssh-example.robot
[ ERROR ] Error in file '/root/ssh-example.robot': Importing test library 'SSHLibrary' failed: ImportError: Importing Paramiko library failed. Make sure you have Paramiko installed.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/__init__.py", line 15, in <module>
from .library import SSHLibrary
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/library.py", line 22, in <module>
from .client import SSHClient
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/client.py", line 20, in <module>
from pythonclient import PythonSSHClient as SSHClient
File "/usr/local/lib/python2.7/dist-packages/SSHLibrary/pythonclient.py", line 21, in <module>
'Importing Paramiko library failed. '
PYTHONPATH:
/usr/local/bin
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
==============================================================================
Ssh-Example
==============================================================================
Execute Deploy command | FAIL |
Parent suite setup failed:
No keyword with name 'Open Connection' found.
------------------------------------------------------------------------------
Ssh-Example | FAIL |
Suite setup failed:
No keyword with name 'Open Connection' found.
Also suite teardown failed:
No keyword with name 'Close All Connections' found.
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
root@92:~# pip install robotframework-sshlibrary
Requirement already satisfied (use --upgrade to upgrade): robotframework-sshlibrary in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): robotframework in /usr/local/lib/python2.7/dist-packages (from robotframework-sshlibrary)
Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.8.0 in /usr/local/lib/python2.7/dist-packages (from robotframework-sshlibrary)
Cleaning up...
【问题讨论】:
-
您能否检查一下 paramiko 库是否已安装?
pip list | grep paramiko。它应该由 pip 自动安装为 sshlibrary 的依赖项。 -
root@92:~# pip list | grep paramiko paramiko (2.1.2)root@92:~# python -V Python 2.7.6paramiko 库已安装。会不会对python版本有依赖? -
罕见情况!但值得检查系统是否有多个 python 版本!和pybot相关的必须用SSH lib更新。
-
@MarkHu 感谢更新。我检查了版本,发现安装了不同的版本。我已经使用
python -m pip install packagename安装了正确的版本,它得到了解决。root@92:~# head -n1 $(which pip) #!/usr/bin/python root@92:~# head -n1 $(which pybot) #!/usr/bin/python -
@Waman 和我在同一个波长上。我已将我的评论转换为答案,并将接受投票作为感谢。 :)
标签: ssh robotframework