As @Sandertjuhh mentioned the best way to do this in code is with a try except, such as:
try:
import pandas as pd
except ImportError:
print("You must have pandas installed to run this script")
exit()
This solves some of your issues, but insuring people have python and pip installed is not something you can handle on your own. I would recommend putting that information into a README file in the project so people are aware, but ultimately it would fall on them to do that part.
But there are some better, and more common python ways to handle the python packages you're using and it has to do with how you are structuring your project. If it is a standalone project (meaning it runs by itself and isn't intended to be imported into another project) a good way is to write a requirements.txt file that contains everything that needs to be installed.
so for example you're requirements.txt file would include:
bs4
and then each new python dependency would go on a new line. From there people just need to type pip install -r requirements.txt
, most people familiar with python will know that and for those that aren't you should also include that in the README file.
If you intend to write your own module (code that other people import into their project like bs4), then you should read up on the setup.py system built into python.