WeasyPrint could not import some external libraries. (indico db upgrade)

Hello,

I tried to ugrade to indico 3.3.1 from 3.2.8 and after running indico db upgrade I get


WeasyPrint could not import some external libraries. Please carefully follow the installation steps before reporting an issue:
https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation
https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#troubleshooting

Traceback (most recent call last):
  File "/opt/indico/.venv/bin/indico", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/cli/util.py", line 108, in invoke
    return self._impl.invoke(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1685, in invoke
    super().invoke(ctx)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask/cli.py", line 385, in decorator
    app = ctx.ensure_object(ScriptInfo).load_app()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask/cli.py", line 330, in load_app
    app: Flask | None = self.create_app()
                        ^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/cli/util.py", line 26, in _create_app
    return make_app()
           ^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/web/flask/app.py", line 424, in make_app
    configure_db(app)
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/web/flask/app.py", line 300, in configure_db
    import_all_models()
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/core/db/sqlalchemy/util/models.py", line 265, in import_all_models
    import_module(module)
  File "/opt/indico/.pyenv/versions/3.12.3/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/modules/receipts/__init__.py", line 12, in <module>
    from indico.modules.receipts.util import can_user_manage_receipt_templates, has_any_receipts, has_any_templates
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/modules/receipts/util.py", line 28, in <module>
    from weasyprint import CSS, HTML, default_url_fetcher
  File "/opt/indico/.venv/lib/python3.12/site-packages/weasyprint/__init__.py", line 419, in <module>
    from .css import preprocess_stylesheet  # noqa isort:skip
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/weasyprint/css/__init__.py", line 27, in <module>
    from .computed_values import COMPUTER_FUNCTIONS
  File "/opt/indico/.venv/lib/python3.12/site-packages/weasyprint/css/computed_values.py", line 9, in <module>
    from ..text.ffi import ffi, pango, units_to_double
  File "/opt/indico/.venv/lib/python3.12/site-packages/weasyprint/text/ffi.py", line 431, in <module>
    pango = _dlopen(
            ^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/weasyprint/text/ffi.py", line 417, in _dlopen
    return ffi.dlopen(names[0])  # pragma: no cover
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library 'pango-1.0-0': pango-1.0-0: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0-0'

Please advise.

Thank you!

Best regards

I might have forgotten to install this

apt install -y --install-recommends postgresql-16 libpq-dev apache2 libapache2-mod-proxy-uwsgi libapache2-mod-xsendfile libxslt1-dev libxml2-dev libffi-dev libpcre3-dev libyaml-dev libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev xz-utils liblzma-dev uuid-dev build-essential redis-server git libpango1.0-dev

After that I got an error

Traceback (most recent call last):
  File "/opt/indico/.venv/bin/indico", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/cli/util.py", line 108, in invoke
    return self._impl.invoke(ctx)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask/cli.py", line 388, in decorator
    return ctx.invoke(f, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/cli/database.py", line 139, in _call_with_plugins
    func(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask/cli.py", line 388, in decorator
    return ctx.invoke(f, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask_migrate/cli.py", line 150, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 111, in wrapped
    f(*args, **kwargs)
  File "/opt/indico/.venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/command.py", line 403, in upgrade
    script.run_env()
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/indico/.venv/lib/python3.12/site-packages/indico/migrations/env.py", line 25, in <module>
    config.set_main_option('sqlalchemy.url', current_app.config.get('SQLALCHEMY_DATABASE_URI'))
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/config.py", line 272, in set_main_option
    self.set_section_option(self.config_ini_section, name, value)
  File "/opt/indico/.venv/lib/python3.12/site-packages/alembic/config.py", line 299, in set_section_option
    self.file_config.set(section, name, value)
  File "/opt/indico/.pyenv/versions/3.12.3/lib/python3.12/configparser.py", line 1184, in set
    super().set(section, option, value)
  File "/opt/indico/.pyenv/versions/3.12.3/lib/python3.12/configparser.py", line 872, in set
    value = self._interpolation.before_set(self, section, option,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/indico/.pyenv/versions/3.12.3/lib/python3.12/configparser.py", line 374, in before_set
    raise ValueError("invalid interpolation syntax in %r at "

ValueError: invalid interpolation syntax in 'postgresql://username:password@host:port/indico?sslmode=require' at position 27

I have the database in another location.

If I change back to default: SQLALCHEMY_DATABASE_URI = 'postgresql:///indico'

I’m able to get indico up and running but cannot login
Then I tried to change back to my external database, and when I try to login I get

“There was a database error while processing your request.”

Can you share your exact SQLALCHEMY_DATABASE_URI that caused the error (just censor your password)? Maybe something in there is wrong.

If you get a DB error, check indico.log for the details. But maybe you did not run indico db upgrade after fixing the error caused by the missing pango library? That’s the most likely reason…

Thanks!

It looks like this: SQLALCHEMY_DATABASE_URI = ‘postgresql://indico:Password@host:5432/indico?sslmode=require’

In the password I have a special character, %

If I look in “/opt/indico/.pyenv/versions/3.12.3/lib/python3.12/configparser.py” on line 373 I see

def before_set(self, parser, section, option, value): tmp_value = value.replace(‘%%’, ‘’) # escaped percent signs tmp_value = self._KEYCRE.sub(‘’, tmp_value) # valid syntax if ‘%’ in tmp_value: raise ValueError("invalid interpolation syntax in %r at " “position %d” % (value, tmp_value.find(‘%’))) return value

I do not know if this is related?

Password has been changed to other character and now it looks good and I can login.

But my logo disappeared from /opt/indico/web/static/images, not a big thing but curious why.

Best regards

You are not supposed to put anything custom in that folder. /opt/indico/web/static is a symlink into the installed indico package, so updating Indico will replace that folder.

Use <CUSTOMIZATION_DIR>/files for such things instead: Settings — Indico 3.3.1 documentation

I see, thank you!

One other question, now when I swich to indico user

I see (.venv) indico@host:~$

I think last time it showed (indico) indico@host

Why does it show (.venv) ?

It looks like we do not pass the --prompt indico arg when recreating the venv during the Python upgrade. This is just something to make the venv showing up more nicely in the bash prompt, so you can safely ignore it.