On Thu, Dec 27, 2012 at 10:53 AM, Ufuk Eskici <ufukesk...@gmail.com> wrote:

> It seems it is looking for Paramiko under wrong folder.
>
> >>> import paramiko
>
> Traceback (most recent call last):
>   File "<pyshell#3>", line 1, in <module>
>     import paramiko
>   File "C:/Users/eufuesk/Desktop\paramiko.py", line 3, in <module>
>     ssh = paramiko.SSHClient()
> AttributeError: 'module' object has no attribute 'SSHClient'
> >>> os.chdir("c:\\Python27")
>
>
> Which directory should I use?
>
>
The problem is that you have a file named paramiko.py in the current
directory. When python executes an import, it looks first in the list of
built-in modules, and then in a set of directories listed in sys.path. The
first directory in sys.path is always the current directory of the script.
So when you do "import paramiko" python looks in the current directory,
finds a file called paramiko.py, and imports that happily.

The lesson is that you should never give your python scripts the same as a
module you're using, because then python will be confused about which file
to import, and you'll be confused why your imported module has none of the
names it should have.

Hugo
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to