nsepy
nsepy copied to clipboard
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
from nsepy import get_history
get_history(symbol='SBIN',s tart=date(2022, 1, 1), end=date(2022, 1, 2))
Traceback (most recent call last):
File "/Users/lennard/PycharmProjects/myproj/data2.py", line 26, in <module>
df = get_latest_data(target_close)
File "/Users/lennard/PycharmProjects/myproj/data2.py", line 11, in get_latest_data
df = get_history(symbol='SBIN',
File "/Users/lennard/PycharmProjects/scalping/venv/lib/python3.9/site-packages/nsepy/history.py", line 138, in get_history
return get_history_quanta(**kwargs)
File "/Users/lennard/PycharmProjects/scalping/venv/lib/python3.9/site-packages/nsepy/history.py", line 143, in get_history_quanta
df = url_to_df(url=url,
File "/Users/lennard/PycharmProjects/scalping/venv/lib/python3.9/site-packages/nsepy/history.py", line 152, in url_to_df
bs = BeautifulSoup(resp.text, 'lxml')
File "/Users/lennard/PycharmProjects/scalping/venv/lib/python3.9/site-packages/bs4/__init__.py", line 248, in __init__
raise FeatureNotFound(
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
pip install lxml
Requirement already satisfied: lxml in ./venv/lib/python3.9/site-packages (4.9.1)
pip install html5lib
Requirement already satisfied: webencodings in ./venv/lib/python3.9/site-packages (from html5lib) (0.5.1)
Idk why the f*** this is happening.
Found a solution. It seems to be an Apple Silicon problem. Compiling lxml from source, fixes the issue:
pip uninstall lxml
curl -L https://github.com/lxml/lxml/releases/download/lxml-4.9.1/lxml-4.9.1.tar.gz -o lxml-4.9.1.tar.gz
tar -xvf lxml-4.9.1.tar.gz
cd lxml-4.9.1
python3 setup.py bdist_wheel
cd dist/
pip3 install lxml-4.9.1-cp310-cp310-macosx_12_0_arm64.whl