pythonweb-scrapingbeautifulsoupmechanicalsoup

lxml error when installing mechanicalsoup in Visual Studio for Python 3.11


I wanted to practice web scraping with Python module MechanicalSoup, but when I started installing it using pip install mechanicalsoup I encountered this error "Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?". I then tried running pip3 install lxml --use-pep517 to install lxml and its dependencies it returned the same error. Note that I'm using Visual Studio Code and installing this in a Python Virtual Environment. I looked up every where for possible resolution but so far nothing I found has worked. Any help would be appreciated. Thanks!


Solution

  • After days of researching and hundreds of videos watched, I finally was able to figure this out. As this turned out, I was using Python 3.11, which mechanicalsoup isn't yet fully compatible. I went back a couple of version of Python, 3.96 specifically and was able to install mechanicalsoup in the first attempt.