Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library? #238

Open
trueToastedCode opened this issue Dec 5, 2022 · 1 comment

Comments

@trueToastedCode
Copy link

trueToastedCode commented Dec 5, 2022

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.

@trueToastedCode
Copy link
Author

trueToastedCode commented Dec 5, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant