"ImportError: cannot import name Browser" with python mechanize
<p>I am unable to use a <a href="https://docs.google.com/document/d/1hEAMNvbPgNzVxNmmDnLdGlVvQwypKhcpjAUAif1Jdkk/" rel="nofollow">mechanize code</a> ). The part that lead to the error is </p>

<pre><code>#!/usr/bin/python
import re
from mechanize import 
br = Browser()
</code></pre>

<p>I also tried </p>

<p>When executing it with python3.5, I find the following error:</p>

<pre><code># python mechanize.py
Traceback (most recent call last):
  File "mechanize.py", line 6, in &lt;module&gt;
    from mechanize import Browser
  File "/root/git/stakexchange-ask-question/mechanize.py", line 6, in &lt;module&gt;
    from mechanize import Browser
ImportError: cannot import name Browser
</code></pre>

<p>This is however precisely what is suggested by the official <a href="http://wwwsearch.sourceforge.net/mechanize/" rel="nofollow">mechanize website</a></p>

<p>If I modify the code to</p>

<pre><code>#!/usr/bin/python
import re
br = mechanize.Browser()
</code></pre>

<p>I also get an error</p>

<pre><code>   # python  mechanize.py
Traceback (most recent call last):
  File "mechanize.py", line 5, in &lt;module&gt;
    import mechanize
  File "/root/git/stakexchange-ask-question/mechanize.py", line 6, in &lt;module&gt;
    br =mechanize.Browser()
AttributeError: module 'mechanize' has no attribute 'Browser'
</code></pre>

<p>I have installed <code>mechanize</code> with </p>

<pre><code>easy_install mechanize
</code></pre>

<p>The <code>python</code> version has to be at least <code>3.0</code> (<a href="http://wwwsearch.sourceforge.net/mechanize/faq.html" rel="nofollow">reference</a>)</p>

<p>Check your python version with</p>

<pre><code>readlink -f $(which python) | xargs -I % sh -c 'echo -n "%: "; % -V'
</code></pre>

<p>But the error didn't came only from this. <code>mechanize</code> wasn't properly installed and I install it again from the <a href="http://wwwsearch.sourceforge.net/mechanize/download.html" rel="nofollow">source code</a>.</p>

python html linux forms mechanize