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?
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.
Comments