cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

ImportError: No module named 'bs4'

IkramMecheri
New Contributor II

Hi,

I would like to do some web scrapping, however I am unable to import the libraries I traditionally use for that task

import requests 
from bs4 import BeautifulSoup

5 REPLIES 5

Chandan
New Contributor II

@one_employee

When you installed bs4 with easy_instal, you installed it system-wide. So your system python can import it, but not your virtualenv python. If you do not need bs4 to be installed in your system python path, uninstall it and keep it in your virtualenv.

I will advise you to uninstall the bs4 library by using this command:

pip uninstall bs4

and then install it using this command:

sudo apt-get install python3-bs4

creigelde
New Contributor II

You need a file named init.py (two underscores on each side) in every folder in the hierarchy. This is what python looks for to know that it should access a particular folder. The files are meant to contain initialization instructions but even if you create them empty this will solve it. To get rid of this error “ImportError: No module named”, you just need to create init.py in the appropriate directory and everything will work fine.

Hayley
New Contributor III
New Contributor III

Did you try

`%pip install bs4 `

requests is standard in the databricks runtime, so you don't have to install it.

Kaniz_Fatma
Community Manager
Community Manager

Hi @ IkramMecheri,

Please try this.

conda install -c anaconda beautifulsoup4

Kaniz_Fatma
Community Manager
Community Manager

Hi @Ikram Mecheri​ ​ , Just a friendly follow-up. Do you still need help, or do the above responses help you find the solution? Please let us know.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!