cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Community Manager
Community Manager

Hi @ IkramMecheri,

Please try this.

conda install -c anaconda beautifulsoup4

Kaniz
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.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.