Opening a HTML file from my computer in web browser
<p>I would like to open a HTML file that is stored in my computer on a web browser but I'm getting an error (see below).</p>

<pre><code>from urllib import urlopen
from webbrowser import open as webopen
from os import getcwd
from os.path import normpath
</code></pre>

<p>I have this code:</p>

<pre><code>def open_html_file():
    path = normpath.abspath('New_News.html')
    url = 'file://' + path

    with open(path, 'w') as f:
        f.write(html)
    webopen.open(url)
</code></pre>

<p>and I'm getting this error when the code is run:</p>

<pre class="lang-none prettyprint-override"><code>AttributeError: 'function' object has no attribute 'abspath'
</code></pre>

<p><code>normpath</code> is a function, and doesn't have a <code>abspath</code> attribute.
I think you meant to do that:</p>

<pre><code>from os.path import abspath

path = abspath('New_News.html')
</code></pre>

python html os.path python-webbrowser