Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on cPanel #1562

Closed
Bohloko opened this issue Feb 7, 2022 · 13 comments
Closed

Error on cPanel #1562

Bohloko opened this issue Feb 7, 2022 · 13 comments

Comments

@Bohloko
Copy link

Bohloko commented Feb 7, 2022

I have deployed my django application to cPanel. It uses Weasyprint for generating PDF reports.
On my local machine running Windows 10, the application works perfectly. But on cPanel I am getting this error, which seems to emanate from Weasyprint when looking at the stack trace towards the bottom.

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 368, in execute
    self.check()
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/management/base.py", line 396, in check
    databases=databases,
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/checks/registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/urls/resolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/urls/resolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/silijuds/silicon_markets/config/urls.py", line 43, in <module>
    path('reports/', include('reports.urls')),
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib64/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/silijuds/silicon_markets/reports/urls.py", line 3, in <module>
    from .views import (DefaultExpensesReportView, FilteredExpensesView, expenses_report_pdf_generator, DefaultSalesReportView,
  File "/home/silijuds/silicon_markets/reports/views.py", line 10, in <module>
    from weasyprint import HTML, CSS
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/__init__.py", line 325, in <module>
    from .css import preprocess_stylesheet  # noqa isort:skip
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/css/__init__.py", line 27, in <module>
    from . import computed_values, counters, media_queries
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/css/computed_values.py", line 16, in <module>
    from ..text.ffi import ffi, pango, units_to_double
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/text/ffi.py", line 412, in <module>
    'libharfbuzz-0.dll')
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/text/ffi.py", line 390, in _dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)

OSError: ctypes.util.find_library() did not manage to locate a library called 'harfbuzz'

I would really appreciate any help
@liZe
Copy link
Member

liZe commented Feb 7, 2022

Hello!

Could you please provide the error message that should be written at the end of the traceback?

@Bohloko
Copy link
Author

Bohloko commented Feb 7, 2022

@liZe I have just edited the original post to include it. I was not aware I left it out while highlighting for copy and paste. Thank you for that.

@Bohloko
Copy link
Author

Bohloko commented Feb 7, 2022

@liZe even when I run $weasyprint --info command, I get the same error:

(silicon/markets:3.7)[silijuds@business106 silicon_markets]$ weasyprint --info
Traceback (most recent call last):
File "/home/silijuds/virtualenv/silicon_markets/3.7/bin/weasyprint", line 5, in
from weasyprint.main import main
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/init.py", line 325, in
from .css import preprocess_stylesheet # noqa isort:skip
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/css/init.py", line 27, in
from . import computed_values, counters, media_queries
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/css/computed_values.py", line 16, in
from ..text.ffi import ffi, pango, units_to_double
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/text/ffi.py", line 412, in
'libharfbuzz-0.dll')
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/weasyprint/text/ffi.py", line 390, in _dlopen
return ffi.dlopen(names[0]) # pragma: no cover
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/cffi/api.py", line 150, in dlopen
lib, function_cache = _make_ffi_library(self, name, flags)
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/cffi/api.py", line 832, in _make_ffi_library
backendlib = _load_backend_lib(backend, libname, flags)
File "/home/silijuds/virtualenv/silicon_markets/3.7/lib/python3.7/site-packages/cffi/api.py", line 827, in _load_backend_lib
raise OSError(msg)
OSError: ctypes.util.find_library() did not manage to locate a library called 'harfbuzz'

@grewn0uille
Copy link
Member

Hello!
Can you please check if harfbuzz is installed on your system? If so, you should have a libharfbuzz file in /usr/lib64.

@Bohloko
Copy link
Author

Bohloko commented Feb 7, 2022

@grewn0uille indeed harfbuzz is not installed on this server. I am trying to find a way to install it - I have failed many times trying to install it using pip and pipenv

@liZe
Copy link
Member

liZe commented Feb 7, 2022

indeed harfbuzz is not installed on this server. I am trying to find a way to install it - I have failed many times trying to install it using pip and pipenv

Harfbuzz can’t be installed with pip, as it is not a Python package. It has to be installed with your distribution package manager. It’s normally a dependency of Pango (that’s probably installed, as WeasyPrint finds it).

Do you have libharfbuzz* files in /usr/lib64?

@Bohloko
Copy link
Author

Bohloko commented Feb 7, 2022

indeed harfbuzz is not installed on this server. I am trying to find a way to install it - I have failed many times trying to install it using pip and pipenv

Harfbuzz can’t be installed with pip, as it is not a Python package. It has to be installed with your distribution package manager. It’s normally a dependency of Pango (that’s probably installed, as WeasyPrint finds it).

Do you have libharfbuzz* files in /usr/lib64?

No I do not have libharfbuzz in /usr/lib64

@liZe
Copy link
Member

liZe commented Feb 7, 2022

No I do not have libharfbuzz in /usr/lib64

Then it means that the package is not installed for some reason. Use the package manager of your distribution to install the Harfbuzz package.

@Bohloko
Copy link
Author

Bohloko commented Feb 7, 2022

No I do not have libharfbuzz in /usr/lib64

Then it means that the package is not installed for some reason. Use the package manager of your distribution to install the Harfbuzz package.

Thank you. I am on it

@Bohloko
Copy link
Author

Bohloko commented Feb 8, 2022

Then it means that the package is not installed for some reason. Use the package manager of your distribution to install the Harfbuzz package.

The problem is with the shared server. I don't have root access and package manager commands. I can only use pip to install third party libraries. My hosting provider has recommended that I upgrade to dedicated server

@liZe liZe closed this as completed in 562a249 Feb 8, 2022
@liZe liZe reopened this Feb 8, 2022
@liZe
Copy link
Member

liZe commented Feb 8, 2022

The problem is with the shared server. I don't have root access and package manager commands. I can only use pip to install third party libraries. My hosting provider has recommended that I upgrade to dedicated server

Sorry to hear that 😒. It’s strange to see that Harfbuzz is not installed while Pango is, but maybe that’s a very, very old version of Pango that doesn’t require Harfbuzz. If that’s the case, you could be lucky with an older version of WeasyPrint, like 52.5. You can install it with pip install "weasyprint==52.5"

@Bohloko
Copy link
Author

Bohloko commented Feb 8, 2022

Sorry to hear that 😒. It’s strange to see that Harfbuzz is not installed while Pango is, but maybe that’s a very, very old version of Pango that doesn’t require Harfbuzz. If that’s the case, you could be lucky with an older version of WeasyPrint, like 52.5. You can install it with pip install "weasyprint==52.5"

Thank you VERY MUCH. Installation of this suggested older version 52.5 did solve my problem. :-)

@liZe liZe closed this as completed Feb 8, 2022
@spangen87
Copy link

pip install "weasyprint==52.5"

Thank you so much! This helped me as well :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants