Check which Python interpreter runs the failing script and print its path.

Install the package into that exact interpreter by running python -m pip install beautifulsoup4.

Run a minimal import test with from bs4 import BeautifulSoup and print a short parse of a small HTML string.

If the import still fails, check whether the script runs inside a virtual environment, container, or notebook kernel that differs from the terminal where pip installed the package, and install it there instead.

If the project uses a requirements file, add beautifulsoup4 to it so a fresh environment does not repeat the failure.