0

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

  • What version of Python are you using? `os.add_dll_directory()` wasn't added until Python 3.8. How did you install `rembg` and `numpy`? – MattDMo Jan 21 '23 at 21:33
  • the "py -m pip install numpy==1.2.30 --target=directory" command in the terminal. I tried a few other ways before but that's what ultimately worked. So, I need python 3.8 to run this? – Massapequa Jan 21 '23 at 22:22
  • I changed my interpreter to python 3.10 and it totally works now. I knew I was missing something. Thanks – Massapequa Jan 21 '23 at 22:33

0 Answers0