我在笔记本电脑上编写了一个python脚本(用2.7.14编写),它使用了paramiko模块。它在我的笔记本上运行得很好。我将这个脚本移动到一个linux机器上,运行它时,我得到一个错误,说找不到paraniko,这当然是因为我将脚本移动到的linux机器没有paramiko模块。我按照以下步骤在Linux上安装paramiko:*从https://pypi.python.org/pypi/robotframework-sshlibrary下载了源代码发行版。
*解压包,导航到解压目录&ran python setup.py install
输出如下:
运行安装运行生成运行生成py运行安装lib creating/usr/local/lib/python2.7/site-packages/sshlibrary copying build/lib/sshlibrary/abstractclient.py->/usr/local/lib/python2.7/site-packages/sshlibrary copying build/lib/sshlibrary/library.py->/usr/local/lib/python2.7/site-packages/sshlibrary copyingbuild/lib/sshlibrary/client.py->/usr/local/lib/python2.7/site-packages/sshlibrary copying build/lib/sshlibrary/init.py->/usr/local/lib/python2.7/site-packages/sshlibrary copying build/lib/sshlibrary/pythonclient.py->/usr/local/lib/python2.7/site-packages/sshlibrary copying build/lib/sshlibrary/config.py->/usr/local/lib/python2.7/site-packages/sshlibrary copying build/lib/sshlibrary/javaclient.py->/usr/local/lib/python2.7/site-packages/sshlibrary copying build/lib/sshlibrary/version.py->/usr/local/lib/python2.7/site-packages/sshlibrary/abstractclient.py到abstractclient.pyc字节编译/usr/local/lib/python2.7/site-packages/sshlibrary/library.py到library.pyc字节编译/usr/local/lib/python2.7/site-packages/sshlibrary/client.py到client.pyc字节编译/usr/local/lib/python2.7/site-packages/sshlibrary/init.py到init.pyc字节编译/usr/local/lib/python2.7/site-packages/sshlibrary/pythonclient.py到pythonclient.pyc字节编译/usr/local/lib/python2.7/site-packages/sshlibary/config.py到config.pyc字节编译/usr/local/lib/python2.7/site-packages/sshlibary/javaclient.py到javaclient.pyc字节编译/usr/local/lib/python2.7/site-packages/sshlibary/version.py到version.pyc运行install-egg-info写入/usr/local/lib/python2.7/site-packages/robotframework\u sshlibary-2.1.3-py2.7.egg-info您在/var/spool/mail/root中有新邮件
然后为了验证这是否成功,我运行了python-c“import sshlibrary:
python-c“导入sshlibrary”
回溯(最近一次调用):file“”,第1行,在文件“/usr/local/lib/python2.7/site packages/sshlibary/init.py”中,第15行,在from.library import sshlibary file“/usr/local/lib/python2.7/site packages/sshlibary/library.py”中,第19行,在from robot.utils import connectioncache importerror中:没有名为robot.utils的模块
我得到了上面的错误。另外,当我尝试运行我的脚本(使用paramiko模块)时,我会得到错误-
python健康检查.py
回溯(最近一次调用):文件“sldcz40_health_check.py”,第2行,in
import paramiko importorror:没有名为paramiko的模块<<<<
当我执行命令'pip install paramiko'时,它说它已经安装了:-需求已经满足(使用--升级到升级):paramiko in/usr/lib/python2.6/site-packages需求已经满足(使用--升级到升级):pycrypto>=1.9 in/usr/lib64/python2.6/site-packages(来自paramiko)
看起来帕拉米科没有被正确导入,有人能告诉我哪里出错了吗?

最佳答案

看起来您已经为robotframework安装了ssh库。因此,当您尝试导入库时,它将查找其robot依赖项。这个库不应该只运行一个python脚本。
使用此命令在计算机上安装paramiko,脚本应该可以正常运行。
http://www.paramiko.org/installing.html#cryptography

10-07 20:23