Python telnetlib seems not imported and returns "no attribute" errors

ThaoD5

I am struggling for 4 hours now on a stupid problem I have with Python.

My version of Python is 2.7.10, the telnet module is included in it as I did watch the whole module list, and I tried some different files in order to check if it's a global error. It is.

Here is one of my tries, in a file called run.py :

import getpass
import sys
import telnetlib

HOST = "localhost"
user = raw_input("Enter your remote account: ")
password = getpass.getpass()

tn = telnetlib.Telnet(HOST)

tn.read_until("login: ")
tn.write(user + "\n")
if password:
    tn.read_until("Password: ")
    tn.write(password + "\n")

tn.write("ls\n")
tn.write("exit\n")

print tn.read_all()

I then run it in my terminal, and get those errors :

Traceback (most recent call last):
  File "run.py", line 3, in <module>
    import telnetlib
  File "/Users/Thao/Desktop/telnetlib.py", line 9, in <module>
    >>> tn = Telnet('www.python.org', 79)   # connect to finger port
AttributeError: 'module' object has no attribute 'Telnet'

I don't find any solution to this, as the telnetlib is already installed natively with Python...

What is the issue with this?

Suever

Based on the error message,

Traceback (most recent call last):
File "run.py", line 3, in
import telnetlib
File "/Users/Thao/Desktop/telnetlib.py", line 9, in
tn = Telnet('www.python.org', 79) # connect to finger port
AttributeError: 'module' object has no attribute 'Telnet'

you have a file named telnetlib.py on your Desktop and python is importing that instead of the real telnetlib module. You will want to either remove the offending file or rename it so as to not interfere with the built-in.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python telnetlib read_until returns cut off string

From Dev

telnetlib errors with read_until

From Dev

Installing Python telnetlib module

From Dev

Python telnetlib ending session

From Dev

Is it possible to add an attribute to an imported class in python?

From Dev

Python assign local value to attribute in imported module

From Dev

Python inheritance returns attribute error

From Dev

Python xlrd returns a no attribute error

From Dev

Python - Telnetlib socket.gaierror:

From Dev

Sqlite database connectected to a python file is causing errors when imported as a package

From Dev

Python import works, but using the imported item fails. Using Django, but this seems like a newbie Python issue

From Dev

Using ciphers in Twisted Python - attribute errors?

From Dev

Python telnetlib to connect to Scrapy Telnet to read stats

From Dev

Python telnetlib telnet.write() dropping messages

From Dev

Python telnetlib and console connection cisco node

From Dev

telnetlib python read_all() not working(hangs)

From Dev

Python step by step telnetlib output message

From Dev

Sort! seems to ignore custom attribute

From Dev

Webscraping with Python3 - Ignoring Duplicate Attribute Errors

From Dev

Errors running python code, attribute error for datetime and strptime type error

From Dev

UBER Python API returns uber_rides.errors.ClientError

From Dev

Post installation script for ucsf-chimerax-daily returns Python errors

From Dev

Custom attribute to handle errors

From Dev

why telnetlib write function not working in my python code?

From Dev

How do I send telnetlib control + c command in python

From Dev

Python Telnetlib read_until '#' or '>', multiple string determination?

From Dev

Python telnetlib client doesn't appear to be opening telnet connection to server

From Dev

Python telnetlib.expect() dot character '.' not working as expected

From Dev

Python telnetlib read functions return more data than expected

Related Related

  1. 1

    Python telnetlib read_until returns cut off string

  2. 2

    telnetlib errors with read_until

  3. 3

    Installing Python telnetlib module

  4. 4

    Python telnetlib ending session

  5. 5

    Is it possible to add an attribute to an imported class in python?

  6. 6

    Python assign local value to attribute in imported module

  7. 7

    Python inheritance returns attribute error

  8. 8

    Python xlrd returns a no attribute error

  9. 9

    Python - Telnetlib socket.gaierror:

  10. 10

    Sqlite database connectected to a python file is causing errors when imported as a package

  11. 11

    Python import works, but using the imported item fails. Using Django, but this seems like a newbie Python issue

  12. 12

    Using ciphers in Twisted Python - attribute errors?

  13. 13

    Python telnetlib to connect to Scrapy Telnet to read stats

  14. 14

    Python telnetlib telnet.write() dropping messages

  15. 15

    Python telnetlib and console connection cisco node

  16. 16

    telnetlib python read_all() not working(hangs)

  17. 17

    Python step by step telnetlib output message

  18. 18

    Sort! seems to ignore custom attribute

  19. 19

    Webscraping with Python3 - Ignoring Duplicate Attribute Errors

  20. 20

    Errors running python code, attribute error for datetime and strptime type error

  21. 21

    UBER Python API returns uber_rides.errors.ClientError

  22. 22

    Post installation script for ucsf-chimerax-daily returns Python errors

  23. 23

    Custom attribute to handle errors

  24. 24

    why telnetlib write function not working in my python code?

  25. 25

    How do I send telnetlib control + c command in python

  26. 26

    Python Telnetlib read_until '#' or '>', multiple string determination?

  27. 27

    Python telnetlib client doesn't appear to be opening telnet connection to server

  28. 28

    Python telnetlib.expect() dot character '.' not working as expected

  29. 29

    Python telnetlib read functions return more data than expected

HotTag

Archive