[GH-ISSUE #16] ModuleNotFoundError: No module named 'rembg' #12

Open
opened 2026-10-30 21:08:19 +00:00 by bsakaguchi · 12 comments
Owner

Originally created by @am576 on GitHub (Apr 19, 2023).
Original GitHub issue: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/issues/16

I have just discovered this script. And after installing it on the fresh web-ui and enabling it in the Extensions tab I got this error

Restarting UI...
Error loading script: postprocessing_rembg.py
Traceback (most recent call last):
  File "C:\stable-diffusion-webui\modules\scripts.py", line 256, in load_scripts
    script_module = script_loading.load_module(scriptfile.path)
  File "C:\stable-diffusion-webui\modules\script_loading.py", line 11, in load_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\stable-diffusion-webui\extensions\stable-diffusion-webui-rembg\scripts\postprocessing_rembg.py", line 5, in <module>
    import rembg
ModuleNotFoundError: No module named 'rembg'
Originally created by @am576 on GitHub (Apr 19, 2023). Original GitHub issue: https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/issues/16 I have just discovered this script. And after installing it on the fresh web-ui and enabling it in the Extensions tab I got this error ``` Restarting UI... Error loading script: postprocessing_rembg.py Traceback (most recent call last): File "C:\stable-diffusion-webui\modules\scripts.py", line 256, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "C:\stable-diffusion-webui\modules\script_loading.py", line 11, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "C:\stable-diffusion-webui\extensions\stable-diffusion-webui-rembg\scripts\postprocessing_rembg.py", line 5, in <module> import rembg ModuleNotFoundError: No module named 'rembg' ```
Author
Owner

@Industrepreneur commented on GitHub (Apr 23, 2023):

Same. Added to colab+ using extension tab, but hit this error.

<!-- gh-comment-id:1519147644 --> @Industrepreneur commented on GitHub (Apr 23, 2023): Same. Added to colab+ using extension tab, but hit this error.
Author
Owner

@epictetito commented on GitHub (Jul 1, 2023):

Same. Linux Debian 12. AUTOMATIC1111 webui v1.4.0

<!-- gh-comment-id:1615895553 --> @epictetito commented on GitHub (Jul 1, 2023): Same. Linux Debian 12. AUTOMATIC1111 webui v1.4.0
Author
Owner

@mattdl-radix commented on GitHub (Jul 6, 2023):

Same, with preceding error:

ERROR: Could not find a version that satisfies the requirement rembg==2.0.38 (from versions: 2.0.41, 2.0.43, 2.0.44, 2.0.45, 2.0.46, 2.0.47, 2.0.48, 2.0.49)
ERROR: No matching distribution found for rembg==2.0.38

I think the problem comes from line pip install rembg==2.0.38 --no-deps --prefer-binary in the install.py that has no matching version. You can change the line in the script to a matching version, e.g. rembg==2.0.41

<!-- gh-comment-id:1623709504 --> @mattdl-radix commented on GitHub (Jul 6, 2023): Same, with preceding error: ``` ERROR: Could not find a version that satisfies the requirement rembg==2.0.38 (from versions: 2.0.41, 2.0.43, 2.0.44, 2.0.45, 2.0.46, 2.0.47, 2.0.48, 2.0.49) ERROR: No matching distribution found for rembg==2.0.38 ``` I think the problem comes from line `pip install rembg==2.0.38 --no-deps --prefer-binary` in the [install.py](https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/blob/master/install.py#L4C21-L4C52) that has no matching version. You can change the line in the script to a matching version, e.g. `rembg==2.0.41`
Author
Owner

@Biniyamseid commented on GitHub (Sep 13, 2023):

same. I have tried to use it in my streamlit app, but got this error.

<!-- gh-comment-id:1718412043 --> @Biniyamseid commented on GitHub (Sep 13, 2023): same. I have tried to use it in my streamlit app, but got this error.
Author
Owner

@gillbates commented on GitHub (Nov 4, 2023):

same problem here in sd 1.6, any ideas why?

<!-- gh-comment-id:1793486897 --> @gillbates commented on GitHub (Nov 4, 2023): same problem here in sd 1.6, any ideas why?
Author
Owner

@padit69 commented on GitHub (Nov 15, 2023):

same. i have using macos 14.1

<!-- gh-comment-id:1811798263 --> @padit69 commented on GitHub (Nov 15, 2023): same. i have using macos 14.1
Author
Owner

@padit69 commented on GitHub (Nov 15, 2023):

` stable-diffusion-webui % rembg --help
Usage: rembg [OPTIONS] COMMAND [ARGS]...

Options:
--version Show the version and exit.
--help Show this message and exit.

Commands:
b for a byte stream as input
i for a file as input
p for a folder as input
s for a http server
`

<!-- gh-comment-id:1811798959 --> @padit69 commented on GitHub (Nov 15, 2023): ` stable-diffusion-webui % rembg --help Usage: rembg [OPTIONS] COMMAND [ARGS]... Options: --version Show the version and exit. --help Show this message and exit. Commands: b for a byte stream as input i for a file as input p for a folder as input s for a http server `
Author
Owner

@check321 commented on GitHub (Nov 27, 2023):

Same, with preceding error:

ERROR: Could not find a version that satisfies the requirement rembg==2.0.38 (from versions: 2.0.41, 2.0.43, 2.0.44, 2.0.45, 2.0.46, 2.0.47, 2.0.48, 2.0.49)
ERROR: No matching distribution found for rembg==2.0.38

I think the problem comes from line pip install rembg==2.0.38 --no-deps --prefer-binary in the install.py that has no matching version. You can change the line in the script to a matching version, e.g. rembg==2.0.41

thx,that works for me

<!-- gh-comment-id:1827100323 --> @check321 commented on GitHub (Nov 27, 2023): > Same, with preceding error: > > ``` > ERROR: Could not find a version that satisfies the requirement rembg==2.0.38 (from versions: 2.0.41, 2.0.43, 2.0.44, 2.0.45, 2.0.46, 2.0.47, 2.0.48, 2.0.49) > ERROR: No matching distribution found for rembg==2.0.38 > ``` > > I think the problem comes from line `pip install rembg==2.0.38 --no-deps --prefer-binary` in the [install.py](https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/blob/master/install.py#L4C21-L4C52) that has no matching version. You can change the line in the script to a matching version, e.g. `rembg==2.0.41` thx,that works for me
Author
Owner

@battester commented on GitHub (Dec 4, 2023):

I met this but I solved it by changing the rembg version in the install.py from 2.0.38 to 2.0.52, bcz when I run the webui script, it showed “ERROR: No matching distribution found for rembg==2.0.38”, so I go to pycharm to check if any version avaliable and then found the 2.0.52 version.
So I fix the version in install.py and then rerun the webui.sh, problem solved.

<!-- gh-comment-id:1837955035 --> @battester commented on GitHub (Dec 4, 2023): I met this but I solved it by changing the rembg version in the install.py from 2.0.38 to 2.0.52, bcz when I run the webui script, it showed “ERROR: No matching distribution found for rembg==2.0.38”, so I go to pycharm to check if any version avaliable and then found the 2.0.52 version. So I fix the version in install.py and then rerun the webui.sh, problem solved.
Author
Owner

@ghost commented on GitHub (Feb 8, 2024):

Open powershell run the following command to activate automatic/A1111 virtualenv, modify path if needed.

C:\automatic\venv\Scripts\Activate.ps1

Run the following to confirm no version of rembg is installed

pip index versions rembg

(venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip index versions rembg
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
rembg (2.0.54)
Available versions: 2.0.54, 2.0.53, 2.0.52, 2.0.51, 2.0.50, 2.0.49, 2.0.48, 2.0.47, 2.0.46, 2.0.45, 2.0.44, 2.0.43, 2.0.41, 2.0.40, 2.0.39, 2.0.38, 2.0.37, 2.0.36, 2.0.35, 2.0.34, 2.0.33, 2.0.32, 2.0.31, 2.0.30, 2.0.29, 2.0.28

Run the following to install the latest version of rembg

pip install rembg==2.0.54 --no-deps --prefer-binary

(venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip install rembg==2.0.54  --no-deps --prefer-binary
Collecting rembg==2.0.54
  Downloading rembg-2.0.54-py3-none-any.whl (32 kB)
Installing collected packages: rembg
Successfully installed rembg-2.0.54

[notice] A new release of pip available: 22.2.1 -> 23.3.2
[notice] To update, run: python.exe -m pip install --upgrade pip
(venv) PS C:\Windows\System32\WindowsPowerShell\v1.0>

Start SD.Next/automatic/A1111 using webui.ps1, go to control, upload picture, select rembg mode and click generate.
It works now

Have a good one, cheers.

<!-- gh-comment-id:1933633078 --> @ghost commented on GitHub (Feb 8, 2024): Open powershell run the following command to activate automatic/A1111 virtualenv, modify path if needed. `C:\automatic\venv\Scripts\Activate.ps1` Run the following to confirm no version of rembg is installed `pip index versions rembg` ``` (venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip index versions rembg WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning. rembg (2.0.54) Available versions: 2.0.54, 2.0.53, 2.0.52, 2.0.51, 2.0.50, 2.0.49, 2.0.48, 2.0.47, 2.0.46, 2.0.45, 2.0.44, 2.0.43, 2.0.41, 2.0.40, 2.0.39, 2.0.38, 2.0.37, 2.0.36, 2.0.35, 2.0.34, 2.0.33, 2.0.32, 2.0.31, 2.0.30, 2.0.29, 2.0.28 ``` Run the following to install the latest version of rembg `pip install rembg==2.0.54 --no-deps --prefer-binary` ``` (venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip install rembg==2.0.54 --no-deps --prefer-binary Collecting rembg==2.0.54 Downloading rembg-2.0.54-py3-none-any.whl (32 kB) Installing collected packages: rembg Successfully installed rembg-2.0.54 [notice] A new release of pip available: 22.2.1 -> 23.3.2 [notice] To update, run: python.exe -m pip install --upgrade pip (venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> ``` Start SD.Next/automatic/A1111 using webui.ps1, go to control, upload picture, select rembg mode and click generate. It works now Have a good one, cheers.
Author
Owner

@DING03015 commented on GitHub (May 20, 2024):

Open powershell run the following command to activate automatic/A1111 virtualenv, modify path if needed.

C:\automatic\venv\Scripts\Activate.ps1

Run the following to confirm no version of rembg is installed

pip index versions rembg

(venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip index versions rembg
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
rembg (2.0.54)
Available versions: 2.0.54, 2.0.53, 2.0.52, 2.0.51, 2.0.50, 2.0.49, 2.0.48, 2.0.47, 2.0.46, 2.0.45, 2.0.44, 2.0.43, 2.0.41, 2.0.40, 2.0.39, 2.0.38, 2.0.37, 2.0.36, 2.0.35, 2.0.34, 2.0.33, 2.0.32, 2.0.31, 2.0.30, 2.0.29, 2.0.28

Run the following to install the latest version of rembg

pip install rembg==2.0.54 --no-deps --prefer-binary

(venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip install rembg==2.0.54  --no-deps --prefer-binary
Collecting rembg==2.0.54
  Downloading rembg-2.0.54-py3-none-any.whl (32 kB)
Installing collected packages: rembg
Successfully installed rembg-2.0.54

[notice] A new release of pip available: 22.2.1 -> 23.3.2
[notice] To update, run: python.exe -m pip install --upgrade pip
(venv) PS C:\Windows\System32\WindowsPowerShell\v1.0>

Start SD.Next/automatic/A1111 using webui.ps1, go to control, upload picture, select rembg mode and click generate. It works now

Have a good one, cheers.

I performed these two steps and other problems occurred
Error occurred when executing Image Rembg (Remove Background):
No module named 'pymatting'
I want to ask what I should do next

<!-- gh-comment-id:2119892520 --> @DING03015 commented on GitHub (May 20, 2024): > Open powershell run the following command to activate automatic/A1111 virtualenv, modify path if needed. > > `C:\automatic\venv\Scripts\Activate.ps1` > > Run the following to confirm no version of rembg is installed > > `pip index versions rembg` > > ``` > (venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip index versions rembg > WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning. > rembg (2.0.54) > Available versions: 2.0.54, 2.0.53, 2.0.52, 2.0.51, 2.0.50, 2.0.49, 2.0.48, 2.0.47, 2.0.46, 2.0.45, 2.0.44, 2.0.43, 2.0.41, 2.0.40, 2.0.39, 2.0.38, 2.0.37, 2.0.36, 2.0.35, 2.0.34, 2.0.33, 2.0.32, 2.0.31, 2.0.30, 2.0.29, 2.0.28 > ``` > > Run the following to install the latest version of rembg > > `pip install rembg==2.0.54 --no-deps --prefer-binary` > > ``` > (venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> pip install rembg==2.0.54 --no-deps --prefer-binary > Collecting rembg==2.0.54 > Downloading rembg-2.0.54-py3-none-any.whl (32 kB) > Installing collected packages: rembg > Successfully installed rembg-2.0.54 > > [notice] A new release of pip available: 22.2.1 -> 23.3.2 > [notice] To update, run: python.exe -m pip install --upgrade pip > (venv) PS C:\Windows\System32\WindowsPowerShell\v1.0> > ``` > > Start SD.Next/automatic/A1111 using webui.ps1, go to control, upload picture, select rembg mode and click generate. It works now > > Have a good one, cheers. I performed these two steps and other problems occurred Error occurred when executing Image Rembg (Remove Background): No module named 'pymatting' I want to ask what I should do next
Author
Owner

@Momin9 commented on GitHub (Jun 5, 2024):

It seems that there's an error loading the script postprocessing_rembg.py due to a missing module named rembg.

To resolve this issue, you need to install the rembg module. You can do this using pip, the Python package manager, by running the following command in your terminal or command prompt:

**pip install rembg**

This command will download and install the rembg module along with its dependencies. After the installation is complete, you should be able to load the script postprocessing_rembg.py without encountering the ModuleNotFoundError.

<!-- gh-comment-id:2149482047 --> @Momin9 commented on GitHub (Jun 5, 2024): It seems that there's an error loading the script postprocessing_rembg.py due to a missing module named rembg. To resolve this issue, you need to install the rembg module. You can do this using pip, the Python package manager, by running the following command in your terminal or command prompt: `**pip install rembg**` This command will download and install the rembg module along with its dependencies. After the installation is complete, you should be able to load the script postprocessing_rembg.py without encountering the ModuleNotFoundError.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AUTOMATIC1111/stable-diffusion-webui-rembg#12
No description provided.