title: I am not able to use RemBg Python Software. Help me
body: <p>I was using RemBg Software provided in this <a href="https://github.com/danielgatis/rembg" rel="nofollow noreferrer">Repository</a>. Whenever I used it. It gives me the following error-</p>
  <pre><code>Failed to import ahead-of-time-compiled modules.
  This is expected on first import.
  Compiling modules and trying again.
  This might take a minute.
  Traceback (most recent call last):
    File &quot;c:\python39\lib\site-packages\pymatting_aot\cc.py&quot;, line 36, in &lt;module&gt;
      import pymatting_aot.aot
  ModuleNotFoundError: No module named 'pymatting_aot.aot'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;c:\python39\lib\runpy.py&quot;, line 197, in _run_module_as_main
      return _run_code(code, main_globals, None,
    File &quot;c:\python39\lib\runpy.py&quot;, line 87, in _run_code
      exec(code, run_globals)
    File &quot;C:\Python39\Scripts\rembg-server.exe\__main__.py&quot;, line 4, in &lt;module&gt;
    File &quot;c:\python39\lib\site-packages\rembg\cmd\server.py&quot;, line 11, in &lt;module&gt;
      from ..bg import remove
    File &quot;c:\python39\lib\site-packages\rembg\bg.py&quot;, line 6, in &lt;module&gt;
      from pymatting.alpha.estimate_alpha_cf import estimate_alpha_cf
    File &quot;c:\python39\lib\site-packages\pymatting\__init__.py&quot;, line 2, in &lt;module&gt;
      import pymatting_aot.cc
    File &quot;c:\python39\lib\site-packages\pymatting_aot\cc.py&quot;, line 54, in &lt;module&gt;
      compile_modules()
    File &quot;c:\python39\lib\site-packages\pymatting_aot\cc.py&quot;, line 8, in compile_modules
      cc = CC(&quot;aot&quot;)
    File &quot;c:\python39\lib\site-packages\numba\pycc\cc.py&quot;, line 65, in __init__
      self._toolchain = Toolchain()
    File &quot;c:\python39\lib\site-packages\numba\pycc\platform.py&quot;, line 78, in __init__
      self._raise_external_compiler_error()
    File &quot;c:\python39\lib\site-packages\numba\pycc\platform.py&quot;, line 121, in _raise_external_compiler_error
      raise RuntimeError(msg)
  RuntimeError: Attempted to compile AOT function without the compiler used by `numpy.distutils` present. Cannot find suitable msvc.
  </code></pre>
  <p>I also tried to start their server by using the rembg-server command but it still not works.
  Can anybody help me?</p>
  <p>Update - Sorry for my behavior. I have installed C++ Build tools. But now when I run their &quot;rembg-server&quot; command it takes too much time to run almost 15 to 25 mins. and After the time it shows this error -</p>
  <pre><code>ERROR:rembg.cmd.server:Exception on / [GET]
  Traceback (most recent call last):
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 2447, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1952, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1821, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File &quot;c:\python39\lib\site-packages\flask\_compat.py&quot;, line 39, in reraise
      raise value
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1950, in full_dispatch_request
      rv = self.dispatch_request()
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1936, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File &quot;c:\python39\lib\site-packages\rembg\cmd\server.py&quot;, line 31, in index
      file_content = urlopen(unquote_plus(url)).read()
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 214, in urlopen
      return opener.open(url, data, timeout)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 517, in open
      response = self._open(req, data)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 534, in _open
      result = self._call_chain(self.handle_open, protocol, protocol +
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 494, in _call_chain
      result = func(*args)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 1375, in http_open
      return self.do_open(http.client.HTTPConnection, req)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 1346, in do_open
      h.request(req.get_method(), req.selector, req.data, headers,
    File &quot;c:\python39\lib\http\client.py&quot;, line 1253, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File &quot;c:\python39\lib\http\client.py&quot;, line 1264, in _send_request
      self.putrequest(method, url, **skips)
    File &quot;c:\python39\lib\http\client.py&quot;, line 1098, in putrequest
      self._validate_path(url)
    File &quot;c:\python39\lib\http\client.py&quot;, line 1198, in _validate_path
      raise InvalidURL(f&quot;URL can't contain control characters. {url!r} &quot;
  http.client.InvalidURL: URL can't contain control characters. '///C:/Users/nutan/Downloads/app anime icon [Music].jpeg' (found at least ' ')
  ERROR:rembg.cmd.server:Exception on / [GET]
  Traceback (most recent call last):
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 1346, in do_open
      h.request(req.get_method(), req.selector, req.data, headers,
    File &quot;c:\python39\lib\http\client.py&quot;, line 1253, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File &quot;c:\python39\lib\http\client.py&quot;, line 1299, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File &quot;c:\python39\lib\http\client.py&quot;, line 1248, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File &quot;c:\python39\lib\http\client.py&quot;, line 1008, in _send_output
      self.send(msg)
    File &quot;c:\python39\lib\http\client.py&quot;, line 948, in send
      self.connect()
    File &quot;c:\python39\lib\http\client.py&quot;, line 919, in connect
      self.sock = self._create_connection(
    File &quot;c:\python39\lib\socket.py&quot;, line 822, in create_connection
      for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    File &quot;c:\python39\lib\socket.py&quot;, line 953, in getaddrinfo
      for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
  socket.gaierror: [Errno 11001] getaddrinfo failed
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 2447, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1952, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1821, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File &quot;c:\python39\lib\site-packages\flask\_compat.py&quot;, line 39, in reraise
      raise value
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1950, in full_dispatch_request
      rv = self.dispatch_request()
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1936, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File &quot;c:\python39\lib\site-packages\rembg\cmd\server.py&quot;, line 31, in index
      file_content = urlopen(unquote_plus(url)).read()
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 214, in urlopen
      return opener.open(url, data, timeout)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 517, in open
      response = self._open(req, data)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 534, in _open
      result = self._call_chain(self.handle_open, protocol, protocol +
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 494, in _call_chain
      result = func(*args)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 1375, in http_open
      return self.do_open(http.client.HTTPConnection, req)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 1349, in do_open
      raise URLError(err)
  urllib.error.URLError: &lt;urlopen error [Errno 11001] getaddrinfo failed&gt;
  ERROR:rembg.cmd.server:Exception on / [GET]
  Traceback (most recent call last):
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 2447, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1952, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1821, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File &quot;c:\python39\lib\site-packages\flask\_compat.py&quot;, line 39, in reraise
      raise value
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1950, in full_dispatch_request
      rv = self.dispatch_request()
    File &quot;c:\python39\lib\site-packages\flask\app.py&quot;, line 1936, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File &quot;c:\python39\lib\site-packages\rembg\cmd\server.py&quot;, line 31, in index
      file_content = urlopen(unquote_plus(url)).read()
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 214, in urlopen
      return opener.open(url, data, timeout)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 514, in open
      req = meth(req)
    File &quot;c:\python39\lib\urllib\request.py&quot;, line 1270, in do_request_
      raise URLError('no host given')
  urllib.error.URLError: &lt;urlopen error no host given&gt;
  </code></pre>
  <p>Edit - How can I use it using code. I wrote this code. Which is provided in their GitHub page. See the code and I am pasting the error below the code-</p>
  <pre><code>from rembg.bg import remove
  import numpy as np
  import io
  from PIL import Image
  
  input_path = './Images/IMG3.jpeg'
  output_path = './Images/out3.jpeg'
  
  f = np.fromfile(input_path)
  result = remove(f)
  img = Image.open(io.BytesIO(result)).convert(&quot;RGBA&quot;)
  img.save(output_path)
  </code></pre>
  <p>Error message -</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\nutan\OneDrive\Desktop\Desktop\Locker\Image and Video Background Removal API and program\program\main.py&quot;, line 10, in &lt;module&gt;
      result = remove(f)
    File &quot;C:\Python39\lib\site-packages\rembg\bg.py&quot;, line 91, in remove
      img = Image.open(io.BytesIO(data)).convert(&quot;RGB&quot;)
    File &quot;C:\Python39\lib\site-packages\PIL\Image.py&quot;, line 904, in convert
      self.load()
    File &quot;C:\Python39\lib\site-packages\PIL\ImageFile.py&quot;, line 249, in load
      raise OSError(
  OSError: image file is truncated (3 bytes not processed)
  </code></pre>
  <p>please fix these error above.</p>
  <p>If somebody knows how to fix this please help. Thanks in Advance.</p>