title: NLTK: set proxy server
body: <p>I'm trying to learn <a href="http://nltk.org/index.html" rel="noreferrer">NLTK</a> - Natural Language Toolkit written in Python and I want install a sample data set to run some examples.</p>
  
  <p>My web connection uses a proxy server,  and I'm trying to specify the proxy address as follows:</p>
  
  <pre><code>&gt;&gt;&gt; nltk.set_proxy('http://proxy.example.com:3128' ('USERNAME', 'PASSWORD'))
  &gt;&gt;&gt; nltk.download()
  </code></pre>
  
  <p>But I get an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: 'str' object is not callable
  </code></pre>
  
  <p>I decided to set up a <code>ProxyBasicAuthHandler</code> before calling <code>nltk.download()</code>:</p>
  
  <pre><code>import urllib2
  
  auth_handler = urllib2.ProxyBasicAuthHandler(urllib2.HTTPPasswordMgrWithDefaultRealm())
  auth_handler.add_password(realm=None, uri='http://proxy.example.com:3128/', user='USERNAME', passwd='PASSWORD')
  opener = urllib2.build_opener(auth_handler)
  urllib2.install_opener(opener)
  
  import nltk
  nltk.download()
  </code></pre>
  
  <p>But now I get <code>HTTP Error 407 - Proxy Autentification Required</code>.</p>
  
  <p>The documentation <a href="http://nltk.org/data.html" rel="noreferrer">says</a> that if the proxy is set to <code>None</code> then this function will attempt to detect the system proxy. But it isn't working.</p>
  
  <p>How can I install a sample data set for NLTK?</p>