You need to install the beautifulsoup4 (bs4) python package.
You can do this in the code env section of the administration page.
In your python code env, in "packages to install" you add :
Adding BeautifulSoup to python code env solved the import
Code samples then failed at line
soup = BeautifulSoup(page, 'html5lib')
FeatureNotFound: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?