[Tutor] how to control putty window
Hugo Arts
hugo.yoshi at gmail.com
Thu Dec 27 11:25:51 CET 2012
On Thu, Dec 27, 2012 at 10:53 AM, Ufuk Eskici <ufukeskici at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121227/ee1d80a3/attachment.html>
More information about the Tutor
mailing list