title: How to get Tor relay info via python + stem on linux?
body: <p>I am trying to control tor on ubuntu linux using python's stem library as instructed on tor's <a href="https://stem.torproject.org/tutorials/the_little_relay_that_could.html" rel="nofollow noreferrer">website</a>. However, when I ran the suggested python code</p>
  <pre><code>from stem.control import Controller
  
  with Controller.from_port(port = 9051) as controller:
      controller.authenticate()  # provide the password here if you set one
  
      bytes_read = controller.get_info(&quot;traffic/read&quot;)
  
      bytes_written = controller.get_info(&quot;traffic/written&quot;)
  
      print &quot;My Tor relay has read %s bytes and written %s.&quot; % (bytes_read, bytes_written)
  </code></pre>
  <p>I get the error:</p>
  <blockquote>
  <p>Traceback (most recent call last):</p>
  <p>File &quot;littleRelay.py&quot;, line 5, in module</p>
  <p>bytes_read = controller.get_info(&quot;traffic/read&quot;)</p>
  <p>File &quot;/usr/local/lib/python2.7/dist-packages/stem/control.py&quot;, line 852, in get_info</p>
  <p>raise exc</p>
  <p>stem.InvalidArguments: GETINFO request contained unrecognized keywords: traffic/read</p>
  </blockquote>
  <p>So how can I get Tor relay info via python+stem on linux?
  I think Tor is running fine because I started tor from the terminal and it says</p>
  <blockquote>
  <p>[notice] Tor has successfully opened a circuit. Looks like client functionality is working.</p>
  <p>[notice] Bootstrapped 100%: Done.</p>
  </blockquote>
  <p>Furthermore, when I run the above python code, the terminal says</p>
  <blockquote>
  <p>[notice] New control connection opened.</p>
  </blockquote>
  <p>P.S. I have also tried the code on a windows pc and it worked. I'm really puzzled now.</p>