doctr icon indicating copy to clipboard operation
doctr copied to clipboard

cannot load library 'pango-1.0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'

Open nithinreddyy opened this issue 3 years ago • 24 comments

Bug description

I installed the library and the GTK project, but it's still throwing an error like

cannot load library 'pango-1.0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'

Can anyone let me know the solution?

I'm using python 3.7.x version

Code snippet to reproduce the bug

from doctr.models import ocr_predictor

Error traceback

~\AppData\Roaming\Python\Python37\site-packages\cffi\api.py in _make_ffi_library(ffi, libname, flags)
    830 def _make_ffi_library(ffi, libname, flags):
    831     backend = ffi._backend
--> 832     backendlib = _load_backend_lib(backend, libname, flags)
    833     #
    834     def accessor_function(name):

~\AppData\Roaming\Python\Python37\site-packages\cffi\api.py in _load_backend_lib(backend, name, flags)
    825         if first_error is not None:
    826             msg = "%s.  Additionally, %s" % (first_error, msg)
--> 827         raise OSError(msg)
    828     return backend.load_library(path, flags)
    829 

OSError: cannot load library 'pango-1.0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'

Environment

I installed the library and when trying to run the code, it's throwing an error

nithinreddyy avatar Feb 08 '22 15:02 nithinreddyy

Hi @nithinreddyy :wave:

Thanks for reporting this! There are a few things missing to identify where this comes from. Would you mind sending the full traceback please (there should be multiple other lines of error traces before the ones you posted)?

Also, could you run the environment collection script and post the result over here please? :pray:

wget https://raw.githubusercontent.com/mindee/doctr/main/scripts/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

Cheers :v:

fg-mindee avatar Feb 08 '22 15:02 fg-mindee

Hi @nithinreddyy 👋

Thanks for reporting this! There are a few things missing to identify where this comes from. Would you mind sending the full traceback please (there should be multiple other lines of error traces before the ones you posted)?

Also, could you run the environment collection script and post the result over here please? 🙏

wget https://raw.githubusercontent.com/mindee/doctr/main/scripts/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

Cheers ✌️

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_30264\4102879070.py in <module>
----> 1 from doctr.models import ocr_predictor

~\AppData\Roaming\Python\Python37\site-packages\doctr\__init__.py in <module>
----> 1 from . import datasets, io, models, transforms, utils
      2 from .file_utils import is_tf_available, is_torch_available
      3 from .version import __version__  # noqa: F401

~\AppData\Roaming\Python\Python37\site-packages\doctr\datasets\__init__.py in <module>
      1 from doctr.file_utils import is_tf_available
      2 
----> 3 from .generator import *
      4 from .cord import *
      5 from .detection import *

~\AppData\Roaming\Python\Python37\site-packages\doctr\datasets\generator\__init__.py in <module>
      2 
      3 if is_tf_available():
----> 4     from .tensorflow import *
      5 elif is_torch_available():
      6     from .pytorch import *  # type: ignore[misc]

~\AppData\Roaming\Python\Python37\site-packages\doctr\datasets\generator\tensorflow.py in <module>
      6 import tensorflow as tf
      7 
----> 8 from .base import _CharacterGenerator, _WordGenerator
      9 
     10 __all__ = ['CharacterGenerator', 'WordGenerator']

~\AppData\Roaming\Python\Python37\site-packages\doctr\datasets\generator\base.py in <module>
      9 from PIL import Image, ImageDraw
     10 
---> 11 from doctr.io.image import tensor_from_pil
     12 from doctr.utils.fonts import get_font
     13 

~\AppData\Roaming\Python\Python37\site-packages\doctr\io\__init__.py in <module>
      1 from .elements import *
----> 2 from .html import *
      3 from .image import *
      4 from .pdf import *
      5 from .reader import *

~\AppData\Roaming\Python\Python37\site-packages\doctr\io\html.py in <module>
      6 from typing import Any
      7 
----> 8 from weasyprint import HTML
      9 
     10 __all__ = ['read_html']

~\miniconda3\envs\gpu\lib\site-packages\weasyprint\__init__.py in <module>
    323 
    324 # Work around circular imports.
--> 325 from .css import preprocess_stylesheet  # noqa isort:skip
    326 from .html import (  # noqa isort:skip
    327     HTML5_UA_COUNTER_STYLE, HTML5_UA_STYLESHEET, HTML5_PH_STYLESHEET,

~\miniconda3\envs\gpu\lib\site-packages\weasyprint\css\__init__.py in <module>
     25 from ..logger import LOGGER, PROGRESS_LOGGER
     26 from ..urls import URLFetchingError, get_url_attribute, url_join
---> 27 from . import computed_values, counters, media_queries
     28 from .properties import INHERITED, INITIAL_NOT_COMPUTED, INITIAL_VALUES
     29 from .utils import get_url, remove_whitespace

~\miniconda3\envs\gpu\lib\site-packages\weasyprint\css\computed_values.py in <module>
     14 
     15 from ..logger import LOGGER
---> 16 from ..text.ffi import ffi, pango, units_to_double
     17 from ..text.line_break import Layout, first_line_metrics, line_size
     18 from ..urls import get_link_attribute

~\miniconda3\envs\gpu\lib\site-packages\weasyprint\text.py in <module>
    259                  'libgobject-2.0.dylib')
    260 pango = dlopen(ffi, 'pango-1.0', 'libpango-1.0-0', 'libpango-1.0.so.0',
--> 261                'libpango-1.0.dylib')
    262 pangocairo = dlopen(ffi, 'pangocairo-1.0', 'libpangocairo-1.0-0',
    263                     'libpangocairo-1.0.so.0', 'libpangocairo-1.0.dylib')

~\miniconda3\envs\gpu\lib\site-packages\weasyprint\text.py in dlopen(ffi, *names)
    253             pass
    254     # Re-raise the exception.
--> 255     return ffi.dlopen(names[0])  # pragma: no cover
    256 
    257 

~\AppData\Roaming\Python\Python37\site-packages\cffi\api.py in dlopen(self, name, flags)
    148                             "or an already-opened 'void *' handle")
    149         with self._lock:
--> 150             lib, function_cache = _make_ffi_library(self, name, flags)
    151             self._function_caches.append(function_cache)
    152             self._libraries.append(lib)

~\AppData\Roaming\Python\Python37\site-packages\cffi\api.py in _make_ffi_library(ffi, libname, flags)
    830 def _make_ffi_library(ffi, libname, flags):
    831     backend = ffi._backend
--> 832     backendlib = _load_backend_lib(backend, libname, flags)
    833     #
    834     def accessor_function(name):

~\AppData\Roaming\Python\Python37\site-packages\cffi\api.py in _load_backend_lib(backend, name, flags)
    825         if first_error is not None:
    826             msg = "%s.  Additionally, %s" % (first_error, msg)
--> 827         raise OSError(msg)
    828     return backend.load_library(path, flags)
    829 

OSError: cannot load library 'pango-1.0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'

The above is the complete traceback error.

nithinreddyy avatar Feb 08 '22 15:02 nithinreddyy

After running python collect_env.py, the below is the output

Collecting environment information...

DocTR version: N/A
TensorFlow version: 2.7.0
PyTorch version: 1.10.0+cu113 (torchvision 0.11.1+cu113)
OpenCV version: 4.5.4
OS: Microsoft Windows 10 Home Single Language
Python version: 3.7.12
Is CUDA available (TensorFlow): Yes
Is CUDA available (PyTorch): Yes
CUDA runtime version: 11.2.67
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

nithinreddyy avatar Feb 08 '22 15:02 nithinreddyy

Hi @nithinreddyy 👋

Thanks for reporting this! There are a few things missing to identify where this comes from. Would you mind sending the full traceback please (there should be multiple other lines of error traces before the ones you posted)?

Also, could you run the environment collection script and post the result over here please? 🙏

wget https://raw.githubusercontent.com/mindee/doctr/main/scripts/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

Cheers ✌️

It's not even showing in the installed libraries list. Below is the image

Capture

nithinreddyy avatar Feb 08 '22 17:02 nithinreddyy

Thanks for the traceback, it comes from weasyprint then :thinking: About your last message, I think I wasn't very clear: would you mind running this snippet:

wget https://raw.githubusercontent.com/mindee/doctr/main/scripts/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

and paste the exact result of here please? :pray:

fg-mindee avatar Feb 08 '22 17:02 fg-mindee

https://raw.githubusercontent.com/mindee/doctr/main/scripts/collect_env.py

The below is the output

Collecting environment information...

DocTR version: N/A
TensorFlow version: 2.7.0
PyTorch version: 1.10.0+cu113 (torchvision 0.11.1+cu113)
OpenCV version: 4.5.4
OS: Microsoft Windows 10 Home Single Language
Python version: 3.7.12
Is CUDA available (TensorFlow): Yes
Is CUDA available (PyTorch): Yes
CUDA runtime version: 11.2.67
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Why it's showing as DocTR version: N/A? I already installed the library

nithinreddyy avatar Feb 09 '22 06:02 nithinreddyy

https://raw.githubusercontent.com/mindee/doctr/main/scripts/collect_env.py

The below is the output

Collecting environment information...

DocTR version: N/A
TensorFlow version: 2.7.0
PyTorch version: 1.10.0+cu113 (torchvision 0.11.1+cu113)
OpenCV version: 4.5.4
OS: Microsoft Windows 10 Home Single Language
Python version: 3.7.12
Is CUDA available (TensorFlow): Yes
Is CUDA available (PyTorch): Yes
CUDA runtime version: 11.2.67
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Why it's showing as DocTR version: N/A? I already installed the library

Can you please mail me to [email protected]? Here i think it'll take so much time. It'd be helpful.

nithinreddyy avatar Feb 09 '22 06:02 nithinreddyy

Hi @nithinreddyy :wave:

Well it's better if we can solve your problem here since it may help others looking for a solution to that :sweat_smile:

It is indeed strange, it seems like you haven't installed docTR yet. Let's try to do this with the latest version:

pip install -e git+https://github.com/mindee/doctr.git#egg=python-doctr[tf]

or

pip install -e git+https://github.com/mindee/doctr.git#egg=python-doctr[tf]

Anyway, back to your problem, we need to get from weasyprint import HTML to work on your system because this is the source of the problem. Perhaps the best way is to check their official installation steps for Windows: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html

fg-mindee avatar Feb 09 '22 10:02 fg-mindee

pip install -e git+https://github.com/mindee/doctr.git#egg=python-doctr[tf]

It's returning the same issue. Below is the image

4

nithinreddyy avatar Feb 09 '22 12:02 nithinreddyy

Oh but then the problem was not on the import, but at the installation step for sure. Have you tried my suggestion of following installation instructions?

Anyway, back to your problem, we need to get from weasyprint import HTML to work on your system because this is the source of the problem. Perhaps the best way is to check their official installation steps for Windows: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html

fg-mindee avatar Feb 09 '22 13:02 fg-mindee

Oh but then the problem was not on the import, but at the installation step for sure. Have you tried my suggestion of following installation instructions?

Anyway, back to your problem, we need to get from weasyprint import HTML to work on your system because this is the source of the problem. Perhaps the best way is to check their official installation steps for Windows: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html

Yes, i tried installing weasyprint. It installed.

I ran 'python -m pip install weasyprint' this command, it worked well. Then i tried running 'python -m weasyprint --info', then it returned the error like pango...

I don't know from where it's the exact problem is.

Weasyprint is installed. Below is the image for your reference

1

nithinreddyy avatar Feb 09 '22 14:02 nithinreddyy

According to your previous traceback, the problem definitely comes from weasyprint. You installed the lib, but apparently, the installation isn't working as it should (cf. pango error). Hard for me to help, we're mostly running Linux here and I haven't been able to reproduce your error :/

Perhaps the best thing to do is to open an issue on their repo https://github.com/Kozea/WeasyPrint ?

fg-mindee avatar Feb 09 '22 14:02 fg-mindee

According to your previous traceback, the problem definitely comes from weasyprint. You installed the lib, but apparently, the installation isn't working as it should (cf. pango error). Hard for me to help, we're mostly running Linux here and I haven't been able to reproduce your error :/

Perhaps the best thing to do is to open an issue on their repo https://github.com/Kozea/WeasyPrint ?

Ok

nithinreddyy avatar Feb 10 '22 06:02 nithinreddyy

Let us know if you hear from them because I'm afraid we cannot do much over here :pray: This is the type of problem we cannot solve by modifying docTR, but we can inform users on how to get around it :+1:

fg-mindee avatar Feb 18 '22 08:02 fg-mindee

Hi @nithinreddyy :wave:

Did you manage to get an answer to your problem? :)

fg-mindee avatar Mar 10 '22 10:03 fg-mindee

Hi @nithinreddyy :wave:

Did you manage to get an answer to your problem? :)

No.

nithinreddyy avatar Mar 10 '22 11:03 nithinreddyy

I managed to solve this issue by the following steps, this is for windows 10, python 3.9.1

  1. Install gtk3-runtime-3.24.14-2020-02-21-ts-win64.exe version (https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases/download/2020-02-21/gtk3-runtime-3.24.14-2020-02-21-ts-win64.exe)
  2. Download harfbuzz-4.0.1 (https://github.com/harfbuzz/harfbuzz/releases/download/4.0.1/harfbuzz-win64-4.0.1.zip)
  3. Copy all content from harbuzz and paste it to GTK3-Runtime Win64\bin

rishabhshah13 avatar Mar 19 '22 20:03 rishabhshah13

Thanks for reporting that @rishabhshah13 :pray: @nithinreddyy this might be worth a try perhaps?

fg-mindee avatar Mar 20 '22 13:03 fg-mindee

Thanks for reporting that @rishabhshah13 :pray: @nithinreddyy this might be worth a try perhaps?

Will try and let you know.

nithinreddyy avatar Mar 20 '22 13:03 nithinreddyy

Thanks for reporting that @rishabhshah13 🙏 @nithinreddyy this might be worth a try perhaps?

It's returning the same error.

nithinreddyy avatar Mar 20 '22 14:03 nithinreddyy

@nithinreddyy Install different versions of GTK3 and check which on works for you

rishabhshah13 avatar Mar 20 '22 15:03 rishabhshah13

@nithinreddyy Install different versions of GTK3 and check which on works for you

Where can i get the different versions? Please let me know if you have any idea.

nithinreddyy avatar Mar 20 '22 15:03 nithinreddyy

I managed to solve this issue by the following steps, this is for windows 10, python 3.9.1

  1. Install gtk3-runtime-3.24.14-2020-02-21-ts-win64.exe version (https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases/download/2020-02-21/gtk3-runtime-3.24.14-2020-02-21-ts-win64.exe)
  2. Download harfbuzz-4.0.1 (https://github.com/harfbuzz/harfbuzz/releases/download/4.0.1/harfbuzz-win64-4.0.1.zip)
  3. Copy all content from harbuzz and paste it to GTK3-Runtime Win64\bin

Download different version from here: https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases

and perform the 2 other steps

rishabhshah13 avatar Mar 20 '22 15:03 rishabhshah13

Checking in: @nithinreddyy did you manage to solve your problem? :)

frgfm avatar Jun 28 '22 15:06 frgfm

Hi @nithinreddyy 👋 any updates ? :)

felixdittrich92 avatar Sep 04 '22 17:09 felixdittrich92

Hi @nithinreddyy 👋 any updates ? :)

No.

nithinreddyy avatar Sep 04 '22 17:09 nithinreddyy

Hi @nithinreddyy 👋 any updates ? :)

No.

Still not working? Then could you please try to install doctr from main branch?

felixdittrich92 avatar Sep 04 '22 17:09 felixdittrich92

Hi @nithinreddyy 👋 any updates ? :)

No.

Still not working? Then could you please try to install doctr from main branch?

Yes, will try.

nithinreddyy avatar Sep 04 '22 17:09 nithinreddyy

Thanks ❤️

felixdittrich92 avatar Sep 04 '22 17:09 felixdittrich92

Should work now (with main branch) otherwise feel free to reopen :)

felixdittrich92 avatar Sep 10 '22 14:09 felixdittrich92