title: Python: ImportError: No module named 'HTMLParser'
body: <p>I am new to Python. I have tried to ran this code but I am getting an error message for ImportError: No module named 'HTMLParser'. I am using Python 3.x. Any reason why this is not working ?</p>
  
  <pre><code>#Import the HTMLParser model
  from HTMLParser import HTMLParser
  
  #Create a subclass and override the handler methods
  class MyHTMLParser(HTMLParser):
  
  #Function to handle the processing of HTML comments
      def handle_comment(self,data):
          print ("Encountered comment: ", data)
          pos = self.getpos()
          print ("At line: ", pos[0], "position ", pos[1])
  
  def main():
      #Instantiate the parser and feed it some html
      parser= MyHTMLParser()
  
      #Open the sample file and read it
      f = open("myhtml.html")
      if f.mode== "r":
          contents= f.read()  #read the entire FileExistsError
          parser.feed()
  
  
  if __name__== "__main__":
      main()
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\bm250199\workspace\test\htmlparsing.py", line 3, in &lt;module&gt;
      from HTMLParser import HTMLParser
  ImportError: No module named 'HTMLParser'
  </code></pre>