stable-diffusion-webui
stable-diffusion-webui copied to clipboard
Mac run script returns ModuleNotFoundError: No module named 'fastapi'
I followed the steps outlined here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Installation-on-Apple-Silicon
and I got to the point where we are to run ./run_webui_mac.sh. However, I am getting the following error:
To make your changes take effect please reactivate your environment
WARNING: overwriting environment variables set in the machine
overwriting variable PYTORCH_ENABLE_MPS_FALLBACK
Already up to date.
Traceback (most recent call last):
File "/Users/<redacted>/Documents/stable-diffusion-webui/webui.py", line 8, in <module>
from fastapi.middleware.gzip import GZipMiddleware
ModuleNotFoundError: No module named 'fastapi'
I ran pip3 install fastapi and tried again, but that didn't work either. I also had rerun the setup script prior to this, not sure if that could cause any potential issues.
i had the same error
Same here
I'll try to reinstall python completely as described in the important notes and let you know if it worked. https://apple.stackexchange.com/questions/284824/remove-and-reinstall-python-on-mac-can-i-trust-these-old-references/285028#285028
Just had the same thing happen to me
I'll try to reinstall python completely as described in the important notes and let you know if it worked. https://apple.stackexchange.com/questions/284824/remove-and-reinstall-python-on-mac-can-i-trust-these-old-references/285028#285028
Hi, did you try this yet?
yes completely. still sitting in front of the same problem. Have reinstalled python 3.10 and also all needed pip modules again manually. unfortunately all this did not work.
ok now works, in my case i had to install the pip modules not in my regular brew folder /opt/homebrew/..
but in the conda environment /Users/..../miniconda/bin
./pip install fastapi
After that i had to install all pip3 modules individually which are described here:
https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/1990
And then magically i execute the commands one by one from run_webui_mac.sh inside terminal.
****Edit works was a little too early I have apparently only brought up the webinterface. Unfortunately it was not yet the solution.
I'm staring at the same problem and have been unable to solve it with selecta-ufuk's solution. Maybe I'm missing something.
Would some be able to walk me through each step/terminal command to fix this?
One step further:
Write in your terminal conda env list
look where your web-ui (created environment from setup) folder is located.
I had to ./pip install fastapi
in the sub /bin folder inside of this environment
Thanks for your help. I seem to be running into error after error and I think I'm too new to this to understand how it all works (like 1-day-old new) 😆
I was successfully able to install and use SD yesterday after Googling each error, but today I can't seem to surpass this problem :(
I still am not able to solve this issue with selecta-ufuk's solution. I'm not exactly sure what I'm doing wrong. When I go into that miniconda bin directory and try to pip install fastapi it says Requirement already satisfied.
I was able to make it work by running pip3 install fastapi
, as well as the rest of the libraries in that issue that selecta-ufuk mentioned earlier (https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/1990), rather than installing them in that miniconda/bin directory. Make sure that the conda environment is activated.
Same problem here. The pip install fastapi into the bin folder didn't help me. Nor did the pip3 install fastapi.
Bummer, because I've had it up and running for over a week and then today, apparently fastapi is neither fast nor helpful. If you come up with the fix . . . . . .
Same problem here. The pip install fastapi into the bin folder didn't help me. Nor did the pip3 install fastapi.
Bummer, because I've had it up and running for over a week and then today, apparently fastapi is neither fast nor helpful. If you come up with the fix . . . . . .
I also had problems today after a git pull , but these came not from the fastapi but from pyTorch. a solution could be found here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2104#issuecomment-1272606556 In my case I comment out the line git pull --rebase inside run_webui_mac.sh after git reset --hard e00b4df7c6f0a13941d6f6ea425eebdaa2bc9318
I'm getting this error as well, tried all of the steps above no luck.
I'm getting this error as well, tried all of the steps above no luck.
I ended up deleting my stable-diffusion-webui folder and then rerunning the brew command to install python wget and so on. Then re-installed automatic1111 stable and things got working again. And working much faster as well. Good luck.
Rather than manually installing each missing dependency one by one, this is the 'proper' and more sustainable way to fix any missing dependency issues:
You can modify your
run_webui_mac.sh
to add a line that tries to install the required dependencies withpip install -r requirements.txt
each time it starts, after it pulls the latest code. This would probably make a sensible default, and is fairly quick to run, so it might be worth someone telling the original author to include it in their setup script to avoid this sort of error for end users in future:Here is what mine looks like:
#!/usr/bin/env bash -l pyenv local anaconda3-2022.05 # This should not be needed since it's configured during installation, but might as well have it here. conda env config vars set PYTORCH_ENABLE_MPS_FALLBACK=1 # Activate conda environment conda activate web-ui # Pull the latest changes from the repo git pull --rebase + # Update the dependencies if needed + pip install -r requirements.txt # Run the web ui python webui.py --deepdanbooru --precision full --no-half --use-cpu Interrogate GFPGAN CodeFormer $@ # Deactivate conda environment conda deactivate
Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4109#issuecomment-1304747007
For the others who said that
pip install -r requirements.txt
didn't work for them, or finding that despitepip install
ing the individual requirements they still don't seem to 'be there', it might be an issue with yourconda
environment, and whichpip
is being used. Sometimes the version you're calling doesn't actually install the packages to the correct place, and so they can't be found later.I have a new theory for you, based on this StackOverflow:
- https://stackoverflow.com/questions/41060382/using-pip-to-install-packages-to-anaconda-environment
What do you see when you activate your conda environment, then run
which -a pip
?If it's only something like:
/opt/conda/bin/pip
And not something like:
/opt/conda/envs/web-ui/bin/pip /opt/conda/bin/pip
Then you can likely fix it by either doing a
conda install pip
then usingpip
as normal, or usingpython -m pip install FOO
instead of usingpip
directly.Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4109#issuecomment-1308357941
I did a
conda install pip
and then usedpython -m
, it looked like it wasn't going to work but then I changed my run script a tiny bit,Curious, what made you think it wasn't going to work? And what was the specific change to the run script that made it work for you? Was it using
requirements_versions.txt
rather thanrequirements.txt
?python -m pip install -r requirements_versions.txt
Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4109#issuecomment-1309356932
Hopefully the above helps people who are still running into this issue 🖤
Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4061#issuecomment-1314398808
I also have the same issue, but on Windows 10!
The problem is that it is creating an venv, and I have no web-ui venv, so I cannot pip install inside.
@0xdevalias Your solution does not seem to be applicable anymore with the latest commit, there is no run_webui_mac.sh file.
there is no
run_webui_mac.sh
file
This file never existed within the main repo, and was only created on macOS after running the install instructions/script from the wiki.
The problem is that it is creating an venv, and I have no web-ui venv, so I cannot pip install inside.
What is the 'it' that is creating a venv
? Can you not just manually activate whatever the venv is, then pip install inside it?