0

I am using visual studio code to run a program in python. I wrote my program in python 3.7 and everything was fine. I tried to install jupyterlab but it needed a new version. So I switched to Python 3.11 (3.11.0 64-bit to be more precise).

When I run my code in the newer Python version it says:

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

For line: soup = BeautifulSoup(page,features="lxml")

According to a 2018 topic here, where the user has the same problem, the most upvoted and accepted answer suggests to do two things. To add "html5lib" and pip install html5lib. I do the hypothesis that I need to do the same about lxml.

That's why I run pip install lxml. Now it returns:

error: subprocess-exited-with-error

  × Running setup.py install for lxml did not run successfully.       
  │ exit code: 1
  ╰─> [96 lines of output]
      Building lxml version 4.9.1.
      Building without Cython.
      Building against pre-built libxml2 andl libxslt libraries       
      running install

And a screenshot. And at the end again:

      *********************************************************************************
      Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
      *********************************************************************************
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lxml

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

And a screenshot. In this Stackoverflow question they suggest to go back a version which sounds like a bad idea. And I do not know if the libraries I want to install will be available there. (In addition, there is no accepted answer and some answers even say to reinstall the entire OS?!)

Then I checked this question and I tried to install pip install C:\Users\@@@@@\Downloads\lxml-4.9.1-cp311-cp311-win_amd64.whl. While everything is there as I downloaded them (screenshot of the folder), it returns an error:

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\@@@@@\\Downloads\\lxml-4.9.1-cp311-cp311-win_amd64.whl'

Information that may be needed:

2
  • beautiful-soup-4.readthedocs.io/en/latest/#installing-a-parser Commented Dec 13, 2022 at 16:00
  • @It_is_Chris I have read the documentation. I have installed both the beautifulsoup4 and html5lib. The "Problems after installation" sections does not include my errors. Neither does "Troubleshooting" section. Commented Dec 13, 2022 at 16:26

1 Answer 1

0

Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?

You can install lxml for your python 3.11 from https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml. And I suggest lxml‑4.9.0‑cp311‑cp311‑win_amd64.whl.

After you downloading it, you can use following command to install it:

pip install C:\path\to\downloaded\file\lxml‑4.9.0‑cp311‑cp311‑win_amd64.whl
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.