Skip to content

Bug: create_image.py fails on modern Linux distributions due to legacy Pango import #912

@yyjeqhc

Description

@yyjeqhc

Description

The create_image.py script currently fails to run on modern Linux distributions (e.g., Ubuntu 22.04+, Fedora 38+, openEuler) due to a ModuleNotFoundError for the pango module.

This issue arises because the script uses the legacy direct import method (import pango), which relies on static PyGTK 2 bindings. Modern Linux systems use PyGObject with GObject Introspection, which requires importing Pango via the gi.repository namespace.

Steps to Reproduce

  1. Set up a clean, modern Linux environment, such as Ubuntu 22.04 or 24.04.

  2. Install the necessary dependencies:

    sudo apt update
    sudo apt install -y python3-cairo python3-gi python3-gi-cairo gir1.2-pango-1.0 python3-pip python3-venv
    #and then,you may create a virtual python env and activate it.
  3. Clone the repository:

    git clone [https://github.com/notofonts/nototools.git](https://github.com/notofonts/nototools.git)
    cd nototools
    
    #install the nototools.
    pip3 install -r requirements.txt
    pip3 install .
  4. Attempt to run the script:

    python3 nototools/create_image.py -h

Actual Behavior

The script fails with the following traceback:

(py_venv) root@MSI:~/nototools# create_image.py -h
/root/py_venv/bin/create_image.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').require('notofonttools==0.2.20')
Traceback (most recent call last):
  File "/root/py_venv/bin/create_image.py", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/root/nototools/nototools/create_image.py", line 33, in <module>
    import pango
ModuleNotFoundError: No module named 'pango'

Expected Behavior

The script should run successfully and display its help message.

Suggested Solution

The import statements in create_image.py should be updated to use the modern PyGObject API. This involves:

  • Importing the gi module.
  • Calling gi.require_version() for Pango and PangoCairo.
  • Importing Pango and PangoCairo from gi.repository.

This change will make the script compatible with standard modern Linux environments. I will submit a Pull Request shortly to address this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions