0

The following code takes in path to an image, removes the background, and saves it to desktop under a name the user decides:

from rembg import remove
from PIL import Image

input_path = input("Please Drag & Drop an image:")   # Takes image path
output_name = input("Give it a name:")
output_path = rf'C:\Users\user\Desktop\{output_name}.png'

input_image = Image.open(input_path)
output = remove(input_image)
output.save(output_path)

It works fine when I run it in PyCharm. I copy the image file, the code executes flawlessly and the output is seen in the desktop. But when I run the code through CMD terminal, it asks for image, and I drag the image to the terminal and it copies the path and everything works well, but when I press enter to begin I get this error and I cannot figure out what is the issue:

cmd screenshot

Does anyone know what the issue is?

Mofi
  • 46,139
  • 17
  • 80
  • 143

1 Answers1

0

You may encounter the loadlibrary failed with error 126 when the problematic application does not have the privileges to access a protected system resource. In this case, launching the problematic application as an administrator may solve the problem. I would recommend running the CMD terminal as an administrator

Daniel M
  • 1
  • 1
  • 2