3

I have downloaded lxml and beautifulsoup4 using pip3 install and both were successful. I have tried uninstalling and installing multiple times, but nothing is working. My beautifulsoup4 works fine, but lxml has not worked once since I downloaded it.

My script starts off with the following import statements which all work fine:

import requests
from urllib.request import urlopen
from bs4 import BeautifulSoup
import lxml

Then begins the code:

base_url = 'http://www.nytimes.com'
r = requests.get(base_url)
soup = BeautifulSoup(r.text, "lxml") 

My error message is as follows:

Mathews-MacBook-Pro:desktop MatLefkofsky$ python3 Homework2_Final_Turnin.py
Traceback (most recent call last):
  File "Homework2_Final_Turnin.py", line 16, in <module>
    soup = BeautifulSoup(r.text, "lxml") 
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bs4/__init__.py", line 165, in __init__
    % ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

How can I fix this issue? I have been on the all the other stack pages that relate and nothing works. I am running OS X 10.11.5 on my Mac.

Yannis P.
  • 2,745
  • 1
  • 24
  • 39
Mat Lefkofsky
  • 31
  • 1
  • 2

0 Answers0