WhyNotHugo / django-afip

⚖️ AFIP invoice integration for django.
https://django-afip.readthedocs.io/
ISC License
48 stars 24 forks source link

Fontconfig error: Cannot load default config file #157

Closed erebodino closed 2 years ago

erebodino commented 2 years ago

The title is the error which shows up when i'm trying to run the migration.

I'm using pipenv as package manager with python 3.10 y django 4.0.7. I tried with another version of django =4.0 but it gave me the same error. I'm using windows 10 as OS. The error is not very verbose so i'm not able to track from where it's start.

WhyNotHugo commented 2 years ago

This library doesn't use fontconfig directly, but it's likely a transitive dependency of weasyprint.

Hard to say what's going on without the full error, can you post the complete stacktrace and any other output that you're getting?

erebodino commented 2 years ago

Exactly, the error belogns to weasyprint, I've managed solved that error, but now i'm stuck in another. It's seems that weasyprint in windows has some very weak points, the new error is:

`Traceback (most recent call last): File "C:\Users\Machina\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Machina\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\Scripts\weasyprint.exe__main.py", line 4, in File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\weasyprint__init__.py", line 336, in from .css import preprocess_stylesheet # noqa isort:skip File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\weasyprint\css\init__.py", line 25, in from . import computed_values, counters, media_queries File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\weasyprint\css\computed_values.py", line 9, in from ..text.ffi import ffi, pango, units_to_double File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\weasyprint\text\ffi.py", line 401, in pango = _dlopen( File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\weasyprint\text\ffi.py", line 385, in _dlopen return ffi.dlopen(names[0]) # pragma: no cover File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\cffi\api.py", line 150, in dlopen lib, function_cache = _make_ffi_library(self, name, flags) File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\cffi\api.py", line 832, in _make_ffi_library backendlib = _load_backend_lib(backend, libname, flags) File "C:\Users\Machina.virtualenvs\erp-budget-integration-TOP-e592yWRN\lib\site-packages\cffi\api.py", line 827, in _load_backend_lib raise OSError(msg)

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

I did everything that it's reported until now in the instructions weasyprint-windows and in the issues reported #589, 721, and 1240

WhyNotHugo commented 2 years ago

Looks like pango is not installed. I've no idea of how to install anything on windows, so can't help here. Check the weasyprint / pango issues and documentation.

erebodino commented 2 years ago

I was able to solved. In my case it was a problem with a .dll from graphviz. I did everything what they said to made a successful instalation, and the problem change from that missing library to Fontconfig error: Cannot load default config file (only that) which was harder to debug due to lack of information in the error. So how I managed to overcome this and keep weasyprint working?

1.- Check the enviroment variables in windows, everithing must be as weasyprint docs says. 2.- Then look for WHERE fontconfig.dll and there was the problem, it's points to Graphviz. 3.- Uninstall weasyprint, GTK3 and Graphviz and then reinstall weasyprint and GTK3, and everything worked.

weasyprint has a issue in #1339

dimanskr commented 1 year ago

I made a django website for windows 10 with the weasyprint library. Also installed GTK+ for Windows Runtime Environment (мversion 3). The same errors were thrown. I tried to swap paths in path, updated windows to 11, but it didn't help. Then i pasted 'sitecustomize.py' like Tontyna https://github.com/Kozea/WeasyPrint/issues/971#issuecomment-544195744 to the virtual environment folder '/Lib/site-packages' another error occurred: Fontconfig error: Cannot load default config file. It turned out that the 'C:\Users\\anaconda3\fontconfig.dll' library is being loaded. In the file 'sitecustomize.py' I changed the line: os.environ['PATH'] = GTK_FOLDER + os.pathsep + os.environ.get('PATH', '') to the line: os.environ['PATH'] = GTK_FOLDER and it WORKS

rob101 commented 1 year ago

fwiw I had this error on a django project with a clean venv, which didn't give a stacktrace; the issue was a windows installation of graphviz outside the environment.

linj121 commented 1 year ago

Thank you! After uninstalling Graphviz on windows 10, everything works fine.