Skip to content
Advertisement

Unable to import paramiko

I wrote a Python script on my laptop(written in 2.7.14) which makes use of paramiko module. It runs just fine on my laptop. I moved this script to a linux box & while running it, I get an error saying paraniko not found which is of course because the linux machine where I moved the script to doesn’t have paramiko module. I followed below procedure to install paramiko on the linux: *Downloaded the source distribution from https://pypi.python.org/pypi/robotframework-sshlibrary. *Extracted the package,navigated to the extracted directory & ran python setup.py install

Output looked like this:

running install running build running build_py running install_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 copying build/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 byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/abstractclient.py to abstractclient.pyc byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/library.py to library.pyc byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/client.py to client.pyc byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/init.py to init.pyc byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/pythonclient.py to pythonclient.pyc byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/config.py to config.pyc byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/javaclient.py to javaclient.pyc byte-compiling /usr/local/lib/python2.7/site-packages/SSHLibrary/version.py to version.pyc running install_egg_info Writing /usr/local/lib/python2.7/site-packages/robotframework_sshlibrary-2.1.3-py2.7.egg-info You have new mail in /var/spool/mail/root

Then to verify if this was successful I ran python -c “import SSHLibrary:
python -c “import SSHLibrary” Traceback (most recent call last): File “”, line 1, in File “/usr/local/lib/python2.7/site-packages/SSHLibrary/init.py”, line 15, in from .library import SSHLibrary File “/usr/local/lib/python2.7/site-packages/SSHLibrary/library.py”, line 19, in from robot.utils import ConnectionCache ImportError: No module named robot.utils

I am getting the above error. Also when I try to run my script(which makes use of paramiko module) I get the error –

python health_check.py

Traceback (most recent call last): File “SLDCz40_health_check.py”, line 2, in
import paramiko ImportError: No module named paramiko <<<<

When i execute the command ‘ pip install paramiko’ it says it’s already installed:- Requirement already satisfied (use –upgrade to upgrade): paramiko in /usr/lib/python2.6/site-packages Requirement already satisfied (use –upgrade to upgrade): pycrypto>=1.9 in /usr/lib64/python2.6/site-packages (from paramiko)

It looks paramiko is not imported correctly, can someone please guide me where am I going wrong ?

Advertisement

Answer

It looks like you have installed the ssh library for RobotFramework. Hence when you try to import the library it is looking for its robot dependencies. That library should not have anything to do with running just a Python script.

Use this to install Paramiko on the machine and your script should be good to go. http://www.paramiko.org/installing.html#cryptography

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement