Unable to work with Stem and Tor
I want to work with Tor through the Stem module. Below is my code for connecting to 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, when running the code, I get the following error: Unable to connect to tor. Are you sure it works?
I turned on Tor and checked the code again and nothing happened. The problem is this line:
if __name__ == '__main__':
controller = connect()
Even if I enter the connect () method into the Python interpreter, I get an error. What is the error and how can I fix it?
+3
source to share
No one has answered this question yet
Check out similar questions: