I want to work with Tor through Stem module.The following is my code to get connected with Tor:
import sys
from stem.connection import connect
if __name__ == '__main__':
controller = connect()
if not controller:
sys.exit(1) # unable to get a connection
print 'Tor is running version %s' % controller.get_version()
controller.close()
However, i get following error when running the code:Unable to connect to tor. Are you sure it's running?
I turned on Tor and tested the code again and nothing happened. The problem is this line:
if __name__ == '__main__':
controller = connect()
Even if I enter the connect() method to Python interpreter I get the error. What is the error and how can I fix it?