Unable to move the Stable Diffusion pipeline to my M1 MacBook

I am following the steps stated here: How to use Stable Diffusion in Apple Silicon (M1/M2).

At my local MacBook M1 machine, I saved the below script in stable-diffusion.py file:

# make sure you're logged in with `huggingface-cli login`
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe = pipe.to("mps")

# Recommended if your computer has < 64 GB of RAM
pipe.enable_attention_slicing()

prompt = "a photo of an astronaut riding a horse on mars"

# First-time "warmup" pass (see explanation above)
_ = pipe(prompt, num_inference_steps=1)

# Results match those from the CPU device after the warmup pass.
image = pipe(prompt).images[0]

Now when I am trying to execute: python stable-diffusion.py from Terminal, I am getting following error:

Traceback (most recent call last):
  File "/Users/apple/Desktop/area_51/stable-diffusion.py", line 2, in <module>
    from diffusers import StableDiffusionPipeline
ModuleNotFoundError: No module named 'diffusers'

In order to fix it even I tried: pip install diffusers, however I still got same error.

Am I missing anything over here?

If you’re looking for an easy way to get SD running locally on your Mac check out https://diffusionbee.com/.

You can also make the SD Web UI run pretty easily on M1 Macs, I’ve done both.

Thanks for the suggestion! For some reasons I still need to set it up. Let me know if you know solution for my query.

I’ve not attempted that approach. Here’s SD via the web UI on Apple Silicon Installation on Apple Silicon · AUTOMATIC1111/stable-diffusion-webui Wiki · GitHub