You are trying to run the command on a generic notebook as a generic pyspark import.
The pipeline module can be accessed only within a context of a pipeline.
please refer this documentation for clarity:
https://docs.databricks.com/aws/en/ldp/developer/python-ref/#gsc.tab=0