AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
141.5k stars 26.74k forks source link

[Bug]: ModuleNotFoundError font_roboto #4398

Closed avrusr closed 1 year ago

avrusr commented 1 year ago

Is there an existing issue for this?

What happened?

I tried to install automatic1111 webui with git clone. So i can update it automatically. Then when it tries to launch the web ui . Then it spit back this error. ModuleNotFoundError: No module named 'font_roboto'.

Steps to reproduce the problem

Install using git clone

What should have happened?

To launch the web ui

Commit where the problem happens

Commit hash: 804d9fb83d0c63ca3acd36378707ce47b8f12599

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

set COMMANDLINE_ARGS=
git pull

Additional information, context and logs

Traceback (most recent call last): File "C:\Users*\Downloads\test\stable-diffusion-webui\launch.py", line 252, in start() File "C:\Users*\Downloads\test\stable-diffusion-webui\launch.py", line 243, in start import webui File "C:\Users*\Downloads\test\stable-diffusion-webui\webui.py", line 13, in from modules import devices, sd_samplers, upscaler, extensions, localization File "C:\Users*\Downloads\test\stable-diffusion-webui\modules\sd_samplers.py", line 11, in from modules import prompt_parser, devices, processing, images File "C:\Users*\Downloads\test\stable-diffusion-webui\modules\processing.py", line 14, in import modules.sd_hijack File "C:\Users*\Downloads\test\stable-diffusion-webui\modules\sd_hijack.py", line 10, in import modules.textual_inversion.textual_inversion File "C:\Users*\Downloads\test\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 13, in from modules import shared, devices, sd_hijack, processing, sd_models, images File "C:\Users*\Downloads\test\stable-diffusion-webui\modules\images.py", line 16, in from fonts.ttf import Roboto File "C:\Users*\Downloads\test\stable-diffusion-webui\venv\lib\site-packages\fonts\ttf__init.py", line 6, in font_files.update(entry_point.load()) File "C:\Users*\Downloads\test\stable-diffusion-webui\venv\lib\site-packages\pkg_resources__init__.py", line 2471, in load return self.resolve() File "C:\Users*\Downloads\test\stable-diffusion-webui\venv\lib\site-packages\pkg_resources__init.py", line 2477, in resolve module = import__(self.module_name, fromlist=['name__'], level=0) ModuleNotFoundError: No module named 'font_roboto' Press any key to continue . . .

tpiatan commented 1 year ago

I get the same issue, after trying every possible solution I've seen on this repo and through Discord:

image

@AUTOMATIC1111 seems to have anticipated this issue and fixed it under https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/197, but the error persists.

Is there a way of simply... using another font entirely? Like something native to Windows, instead of roboto?

0xdevalias commented 1 year ago

Not sure if this will work for your specific issue here, but I suspect that it possibly will:

You can modify your run_webui_mac.sh to add a line that tries to install the required dependencies with pip 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 despite pip installing the individual requirements they still don't seem to 'be there', it might be an issue with your conda environment, and which pip 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:

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 using pip as normal, or using python -m pip install FOO instead of using pip 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 used python -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 than requirements.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

tpiatan commented 1 year ago

Ok wow... So many questions. This is likely me not being adept at this at all, but I don't have any conda environment... I thought SD installed a virtual environment every time it ran? As a result I can't try any of the solutions above as they all require me to activate a conda environment first.

I don't have miniconda/Anaconda installed. Should I use them instead or stick with the plain old cmd? For the better part of the last 2 months, I've been using Miniconda and I had to uninstall it because its python version was 3.9, whereas my system's python is 3.10. What's the best solution?

Every other troubleshooting attemps I've tried so far has been through cmd directly. This is also where I tried python -m pip install requirements_versions.txt like mentioned above, but with no success.

0xdevalias commented 1 year ago

So the exact specifics of those above solutions were written with macOS users in mind. It looks like you're running on windows, which I don't have any direct experience with; but I suspect that where conda is mentioned you can probably substitute it for the equivalent virtual environment commands.

0xdevalias commented 1 year ago

This is also where I tried python -m pip install requirements_versions.txt like mentioned above, but with no success.

Did you try that after doing whatever was needed to activate the virtual environment?

tpiatan commented 1 year ago

Ok, I think I understand what you mean:

image

This is just telling me that the package already exists in my files... which I already knew:

image

Error still there... Am I missing something?

0xdevalias commented 1 year ago

Did you try that after doing whatever was needed to activate the virtual environment?

Looking at webui.sh, this is how it seems to activate the venv:

source "${venv_dir}"/bin/activate
jaovito commented 1 year ago

I fix it doing that:

Go to the venv/Lib/site-packages, and delete all folders with roboto or font-roboto or font_roboto in the name, after run this command in the stable-diffusion-webui folder (the folder that you clone) to enter in the python venv:

OBS: You need to run these commands on the directory folder in the terminal.

(Windows)

$ venv\Scripts\activate

After doing that, run this command:

$ pip install font-roboto

And fix-it, you can run:

$ python launch.py
tpiatan commented 1 year ago

My friend, you are a LIFESAVER! That did it! I kept trying to install font-roboto without activating the virtual environment... Thank you!!!

Misky101 commented 1 year ago

I'm having this problem too. Complicating matters, I have very little Windows experience and even less Linux so Jaovito's solution is very hard for me to recreate. I found 1 "font-roboto" folder in Windows which I hand deleted. When he says to run these commands in the directory folder, I'm not sure if this is the Windows terminal or the Python terminal.

I tried "cd C:\Users\mynamehere\Documents\SDlocal\venv\lib\site-packages\pkg_resources" in the python terminal to get to where I think this package is supposed to live, but any command I issue in Python results in an error. I'm not sure when / how I get to the point I'm ready to issue the next commands he suggests-

$ venv\Scripts\activate $ pip install font-roboto $ python launch.py

thanks for any instructions you can offer.

Batman313v commented 1 year ago

For anyone still having this issue, Make sure you upgrade pip inside the venv. For some reason the existing version doesn't install font_roboto correctly

mohsenemx commented 1 year ago

So this doesn't work for me. it's still the same error

mohsenemx commented 1 year ago

Ok So I fixed it (if you're still having problems):

  1. Open a administrator PS anywhere, and execute: Set-ExecutionPolicy Unrestricted and close it.
  2. Open a PS terminal in stable-diffusion-webui root (the folder that you cloned).
  3. Goto venv/Lib/site-packages and remove every folder named roboto, font-roboto and fonts.
  4. Execute: venv\Scripts\activate.
  5. Execute pip install pip --upgrade to update the pip.
  6. Goto %appdata%\local\pip and remove the cache folder.
  7. Go back to PS terminal that you ran venv\Scripts\activate in.
  8. Execute pip install font-roboto or pip install font-roboto --upgrade.
  9. You should be done, Go back to the root directory and run WebUi-user.bat and Enjoy!

(Special thanks to @jaovito for helping in the comments)

GSVlastingdamage commented 1 year ago

Ok So I fixed it (if you're still having problems):

  1. Open a administrator PS anywhere, and execute: Set-ExecutionPolicy Unrestricted and close it.
  2. Open a PS terminal in stable-diffusion-webui root (the folder that you cloned).
  3. Goto venv/Lib/site-packages and remove every folder named roboto, font-roboto and fonts.
  4. Execute: venv\Scripts\activate.
  5. Execute pip install pip --upgrade to update the pip.
  6. Goto %appdata%\local\pip and remove the cache folder.
  7. Go back to PS terminal that you ran venv\Scripts\activate in.
  8. Execute pip install font-roboto or pip install font-roboto --upgrade.
  9. You should be done, Go back to the root directory and run WebUi-user.bat and Enjoy!

(Special thanks to @jaovito for helping in the comments)

Where would I find %appdata%\local\pip

alfredofrog1 commented 1 year ago

Ok So I fixed it (if you're still having problems):

  1. Open a administrator PS anywhere, and execute: Set-ExecutionPolicy Unrestricted and close it.
  2. Open a PS terminal in stable-diffusion-webui root (the folder that you cloned).
  3. Goto venv/Lib/site-packages and remove every folder named roboto, font-roboto and fonts.
  4. Execute: venv\Scripts\activate.
  5. Execute pip install pip --upgrade to update the pip.
  6. Goto %appdata%\local\pip and remove the cache folder.
  7. Go back to PS terminal that you ran venv\Scripts\activate in.
  8. Execute pip install font-roboto or pip install font-roboto --upgrade.
  9. You should be done, Go back to the root directory and run WebUi-user.bat and Enjoy!

(Special thanks to @jaovito for helping in the comments)

how do i go to venv/Lib/site-packages

mohsenemx commented 1 year ago

Where would I find %appdata%\local\pip

Just put that text in your Windows Explorer path bar

mohsenemx commented 1 year ago

how do i go to venv/Lib/site-packages

Goto where you cloned the repo, and run it once, after that, there should be a folder, called "venv" enter it and continue with my tutorial

MilkDeLeche commented 1 year ago

Ok So I fixed it (if you're still having problems):

  1. Open a administrator PS anywhere, and execute: Set-ExecutionPolicy Unrestricted and close it.
  2. Open a PS terminal in stable-diffusion-webui root (the folder that you cloned).
  3. Goto venv/Lib/site-packages and remove every folder named roboto, font-roboto and fonts.
  4. Execute: venv\Scripts\activate.
  5. Execute pip install pip --upgrade to update the pip.
  6. Goto %appdata%\local\pip and remove the cache folder.
  7. Go back to PS terminal that you ran venv\Scripts\activate in.
  8. Execute pip install font-roboto or pip install font-roboto --upgrade.
  9. You should be done, Go back to the root directory and run WebUi-user.bat and Enjoy!

(Special thanks to @jaovito for helping in the comments)

executing will open up my pc to malicious scripts , can i turn it back on when im done? also how do i open a terminal in the root folder , to me when i copy the address it says C:\Users\mange\stable-diffusion-webui : The term 'C:\Users\mange\stable-diffusion-webui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

mohsenemx commented 1 year ago

Yes

Ok So I fixed it (if you're still having problems):

  1. Open a administrator PS anywhere, and execute: Set-ExecutionPolicy Unrestricted and close it.
  2. Open a PS terminal in stable-diffusion-webui root (the folder that you cloned).
  3. Goto venv/Lib/site-packages and remove every folder named roboto, font-roboto and fonts.
  4. Execute: venv\Scripts\activate.
  5. Execute pip install pip --upgrade to update the pip.
  6. Goto %appdata%\local\pip and remove the cache folder.
  7. Go back to PS terminal that you ran venv\Scripts\activate in.
  8. Execute pip install font-roboto or pip install font-roboto --upgrade.
  9. You should be done, Go back to the root directory and run WebUi-user.bat and Enjoy!

(Special thanks to @jaovito for helping in the comments)

executing will open up my pc to malicious scripts , can i turn it back on when im done? also how do i open a terminal in the root folder , to me when i copy the address it says C:\Users\mange\stable-diffusion-webui : The term 'C:\Users\mange\stable-diffusion-webui' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Yes you can turn execution policy back on when you're done. Open root folder, copy it's path. Open powershell, write cd "your path" (include those quotes)