skip to Main Content

I’m making a telegram bot that sends tasks from the site https://phys-ege.sdamgia.ru / You need to send an Image.

As I understand it, you need to convert svg to png or jpeg, but when using the pyvips library it gives an error

Traceback (most recent call last):
  File "D:/Питончик/hbntdfg.py", line 1, in <module>
    import pyvips
  File "C:UsersdenveAppDataLocalProgramsPythonPython311Libsite-packagespyvips__init__.py", line 70, in <module>
    gobject_lib = ffi.dlopen(_gobject_libname)
  File "C:UsersdenveAppDataLocalProgramsPythonPython311Libsite-packagescffiapi.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:UsersdenveAppDataLocalProgramsPythonPython311Libsite-packagescffiapi.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:UsersdenveAppDataLocalProgramsPythonPython311Libsite-packagescffiapi.py", line 828, in _load_backend_lib
    return backend.load_library(path, flags)
OSError: cannot load library 'C:Program Files (x86)GTK2-Runtimebinlibgobject-2.0-0.dll': error 0xc1

2

Answers


  1. Chosen as BEST ANSWER
            x=1
            r=random.randint(1,69)
            url = 'https://phys-ege.sdamgia.ru/test?theme=403&print=true'
            response = requests.get(url)
            soup = BS(response.content, "html.parser")
            data = soup.find_all('div', class_="nobreak")
            data_2 = soup.find_all('div', style= "clear:both;display:none")
            for i in data:
                v = i.find('p',class_= "left_margin")
                if x == r:
                    try:
                        z = v.find('img').get('src')
                        svg2png(url='https://ege.sdamgia.ru'+ z,write_to='task.png')
                        photo = open("D:/Питончик/task.png","rb")
                        bot.send_photo(chat_id=message.chat.id, photo=photo)
                    except AttributeError:
                        print('No photo')
                    bot.send_message(message.chat.id,v.text)
    

  2. I think you are seeing DLL clashes.

    pyvips is trying to open libgobject-2.0-0.dll and it’s finding the one you have in C:Program Files (x86)GTK2-Runtime. This is probably pretty old and won’t work with libvips, which needs quite a recent libgobject.

    Have a look at the win install notes:

    https://github.com/libvips/pyvips#windows-install

    And make sure you follow the instructions for python 3.8 and later.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search