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

3 REPLIES 3

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
Databricks Employee
Databricks Employee

Did you try

`%pip install bs4 `

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

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group