Remove Image Background (AI) in Inkscape doesn't work

General Forum
mirekjl
Phoca Member
Phoca Member
Posts: 21
Joined: 27 Jun 2022, 21:48

Remove Image Background (AI) in Inkscape doesn't work

Post by mirekjl »

Hello, I installed Inkscape, Phoca Remove Image Backgraound and rembg. Rembg works in the command line, but Remove Image Background (AI) in Inkscape doesn't work. Here is the output:
...\AppData\Roaming\inkscape\extensions\remove_bg.py:26: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.spawn import find_executable
Traceback (most recent call last):
File ...\AppData\Roaming\inkscape\extensions\remove_bg.py", line 34, in <module>
from rembg import new_session, remove
ModuleNotFoundError: No module named 'rembg'
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48648
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Remove Image Background (AI) in Inkscape doesn't work

Post by Jan »

Hi, I think, the warning is not the problem, but inkscape cannot find the module rembg.

Python is similar to Javascript, it can be installed globaly or in some specific virtual environemt. So the question is where did you install the rembg module? Globally or somewhere on virtual place where inkscape cannot access?

Jan
If you find Phoca extensions useful, please support the project
mirekjl
Phoca Member
Phoca Member
Posts: 21
Joined: 27 Jun 2022, 21:48

Re: Remove Image Background (AI) in Inkscape doesn't work

Post by mirekjl »

Hello. First, I installed Python 3.12 without administrative rights in C:\Users\MyUser\AppData\Local\Programs\Python\Python312. Then I used pip install rembg to C:\Users\MyUser\AppData\Local\Programs\Python\Python312\Scripts. Environment variables are set for the user MyUser. The Phoca script is uzipped to the folder C:\Users\MyUser\AppData\Roaming\inkscape\extensions\phoca-inkscape-remove-bg-v1.0.1.
Rembg works in the console, but still doesn't work in Inkscape (ModuleNotFoundError: No module named 'rembg').
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48648
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Remove Image Background (AI) in Inkscape doesn't work

Post by Jan »

Hi, there is no problem with the script as it is normally loaded in Inkscape. The problem is, Inkscape cannot find the Python module Rembg, so this mostly means, the Inkscape has no access to python environment which includes the Rembg library :Idea:
If you find Phoca extensions useful, please support the project
mirekjl
Phoca Member
Phoca Member
Posts: 21
Joined: 27 Jun 2022, 21:48

Re: Remove Image Background (AI) in Inkscape doesn't work

Post by mirekjl »

Hello. I installed Anaconda and created an environment with rembg. Then I pointed preferences.xml in Inkscape to python path. It works now. Looks good. Good work, Jan.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48648
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Remove Image Background (AI) in Inkscape doesn't work

Post by Jan »

Great to hear it. Thank you for the info.

Jan
If you find Phoca extensions useful, please support the project
Post Reply