Vitor Mazuco
Vitor Mazuco

Reputation: 190

Ubuntu 14.04: ImportError: No module named client

I tried to use Paramiko in my Python 2.7, but I can't use it on my script.

I also install all packet

sudo pip install paramiko
pip install paramiko
sudo apt-get install python-paramiko

But It doesn't work

See my Script

 #!/usr/bin/python 
 #

 from paramiko.client import SSHClient
 import paramiko
 client = SSHClient

 client.load_system_host_keys()
 client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
 client.connect("192.168.1.60")
 stdin, stdout, stderr = client.exec_command("ls -la")

 if stderr.channel.recv_exit_status() != 0:
    print stderr.channel.recv_exit_status()
    print stderr.read()

 else:
    print stdout.read()

It returns

   vitor@vitor-pc:~/Linux/Python/Arquivos de Configuração/Paramiko$ python paramiko.py
   Traceback (most recent call last):
   File "paramiko.py", line 4, in <module>
   from paramiko.client import SSHClient
   File "/home/vitor/Linux/Python/Arquivos de Configuração/Paramiko/paramiko.py", line 4, in <module>
   from paramiko.client import SSHClient
   ImportError: No module named client

I also tried to use this Answers and and delete my /usr/local/lib/python2.7 But nothing change.

This error appear only in Ubuntu? Or my code is wrong?

Upvotes: 1

Views: 1833

Answers (2)

khelili miliana
khelili miliana

Reputation: 3822

There are two others methodes for add modules in python :

The first :

  1. Download the package.
  2. Create directory and paste the package in it.
  3. Tap in the terminal :
  4. export PYTHONPATH=$PYTHONPATH:path_of_package

The second :

  1. open python interpreter:
  2. import sys
  3. sys.path.insert(0, "path_of_package")

Upvotes: 1

e4c5
e4c5

Reputation: 53774

Here is the problem

 vitor@vitor-pc:~/Linux/Python/Arquivos de Configuração/Paramiko$ python paramiko.py 

You have named your own script as paramiko.py thus python thinks your own script is the where it can find the 'paramiko' module. But it isn't. Just rename your file to something else and you will be fine.

Upvotes: 1

Related Questions