'html_table_parser not working in command prompt but working in python jupyter notebooks
I am running a batch file which runs my python code through the command prompt. However, when running the code it gives me the following error:
from html_table_parser import HTMLTableParser
ModuleNotFoundError: No module named 'html_table_parser'
However, when running my code through Jupyter-notebooks its works just fine. Is it because it isn't properly downloaded. My python.exe is found in Anaconda.
My code is the following
import urllib.request
from pprint import pprint
from html_table_parser import HTMLTableParser
import datetime
# pretty-print python data structures
from pprint import pprint
# for parsing all the tables present on the website
# for converting the parsed data in a
# pandas dataframe
import pandas as pd
from bs4 import BeautifulSoup
# Opens a website and read its
# binary contents (HTTP Response Body)
def url_get_contents(url):
# Opens a website and read its
# binary contents (HTTP Response Body)
#making request to the website
req = urllib.request.Request(url=url)
f = urllib.request.urlopen(req)
#reading contents of the website
return f.read()
xhtml = url_get_contents("https://en.wikipedia.org/wiki/Searching").decode('utf-8')
# Defining the HTMLTableParser object
p = HTMLTableParser()
content = urllib.request.urlopen("https://en.wikipedia.org/wiki/Searching")
read_content = content.read()
Solution 1:[1]
pip install html-table-parser-python3
I have solved it by installing the above package.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Syscall |
