bs4.Feature Not Found Error Message
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Alteryx Community,
Has anyone seen this error message before when running an Analytic App which uses python?
The app works on my own desktop but when a friend tried to run it, he got the error message shown below. I am wondering whether he needs to download more packages that I already have downloaded but forgot to include in the Python script. The python script embedded in the Analytic App is as follows:
#################################
# List all non-standard packages to be imported by your
# script here (only missing packages will be installed)
from ayx import Package
from ayx import Alteryx
Package.installPackages(['requests'])
Package.installPackages(['bs4'])
#################################
import requests
from urllib import request, response, error, parse
from urllib.request import urlopen
from bs4 import BeautifulSoup
import pandas as pd
#################################
stock = 'UBER'
url_competitors = 'https://money.cnn.com/quote/competitors/competitors.html?symb='+ stock
#################################
# Fetch the html file
response = urlopen(url_competitors)
html_doc = response.read()
#################################
# Parse the html file
soup = BeautifulSoup(html_doc, 'html.parser')
#################################
# Format the parsed html file
strhtm = soup.prettify()
#################################
section = soup.find_all('a', class_='wsod_symbol')
#################################
print(section)
#################################
list_rows = []
str_cells = str(section)
clean_text = BeautifulSoup(str_cells,"lxml").get_text()
list_rows.append(clean_text)
#################################
print(clean_text)
#################################
df = pd.DataFrame(list_rows)
#################################
print(df)
#################################
Alteryx.write(df,1)
################################
- Labels:
- Error Message
- Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
hey @charfeldman
I believe you're right -
It has issue with this line: clean_text = BeautifulSoup(str_cells,"lxml").get_text()
Im not as familiar with BS4 as i'd like to be, but i believe lxml has to be imported too, so try adding:
Package.installPackages(['lxml'])
At the start of your code.
Let me know if this helps!
TheOC
EDIT: from looking at some documentation on lxml, you may also need this too:
Package.installPackages(['html5lib'])
