Errors in image background remover using Python with rembg and PIL - getting error in the modules I think?

1.1k Views Asked by At

So I'm making a super simple python program using rembg and PIL that I found on the internet. I'm getting an error that seems to be an issue with the module rembg or numpy, but I can't be sure. This is what the code looks like:

from rembg import remove
from PIL import Image

input_path = 'ballroom1.jpg'
output_path = 'output.png'
input = Image.open(input_path)
output = remove(input)
output.save(output_path)

Now these are the errors:


Traceback (most recent call last):
  File "D:\PyCharm\BackgroundRemover\Remove.py", line 1, in <module>
    from rembg import remove
  File "D:\PyCharm\Python\rembg\__init__.py", line 5, in <module>
    from .bg import remove
  File "D:\PyCharm\Python\rembg\bg.py", line 5, in <module>
    import numpy as np
  File "D:\PyCharm\Python\numpy\__init__.py", line 124, in <module>
    from numpy.__config__ import show as show_config
  File "D:\PyCharm\Python\numpy\__config__.py", line 12, in <module>
    os.add_dll_directory(extra_dll_dir)
AttributeError: module 'os' has no attribute 'add_dll_directory'

Now, I have numpy 1.23.5 rembg 2.0.30

Any help understanding what's going on would be much appreciated. Thanks

I've tried reinstalling both numpy and rembg but received the same errors

0

There are 0 best solutions below