Urllib problom: AttributeError: 'module' object has no attribute 'maketrans'
<p>The environment is Win10 64-bit, Python 2.7.12, Anaconda.
The code is quite simple for web-scrapy:</p>

<pre><code>import urllib

fhand = urllib.urlopen('http://www.reddit.com')
for line in fhand:
    print line.strip()
</code></pre>

<p>And the result is weird:</p>

<pre><code>0.8475
Traceback (most recent call last):
  File ".\catch-web.py", line 1, in &lt;module&gt;
    import urllib
  File "C:\Users\XxX\Anaconda2\lib\urllib.py", line 30, in &lt;module&gt;
    import base64
  File "C:\Users\XxX\Anaconda2\lib\base64.py", line 98, in &lt;module&gt;
    _urlsafe_encode_translation = string.maketrans(b'+/', b'-_')
AttributeError: 'module' object has no attribute 'maketrans'
</code></pre>

<p>The code could run on the other PC with iPython, but could not work on this one. I have re-installed Anaconda for several times, but failed.</p>

<p>I would appreciate it if you could solve it. </p>

<p>try Spyder, everything works.</p>

<p>still no idea for the problem.</p>

python anaconda urllib