Skip to content

[Python-pip] I can't install toga #1780

Open
@Heus-Sueh

Description

@Heus-Sueh

What happened?

If I try to install the toga library through pip inside .venv it gives me this error:

❯ pip install toga
Collecting toga
  Using cached toga-0.4.1-py3-none-any.whl.metadata (4.0 kB)
Collecting toga-gtk==0.4.1 (from toga)
  Using cached toga_gtk-0.4.1-py3-none-any.whl.metadata (3.0 kB)
Collecting gbulb>=0.5.3 (from toga-gtk==0.4.1->toga)
  Using cached gbulb-0.6.4-py3-none-any.whl (17 kB)
Requirement already satisfied: pycairo>=1.17.0 in /nix/store/67mw87bh762ismbnbd239xw59yv76p9k-python3.12-pycairo-1.25.1/lib/python3.12/site-packages (from toga-gtk==0.4.1->toga) (1.25.1)
Collecting pygobject>=3.46.0 (from toga-gtk==0.4.1->toga)
  Using cached PyGObject-3.46.0.tar.gz (723 kB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [45 lines of output]
      Collecting setuptools
        Using cached setuptools-69.0.3-py3-none-any.whl.metadata (6.3 kB)
      Collecting wheel
        Using cached wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB)
      Collecting pycairo
        Using cached pycairo-1.25.1.tar.gz (347 kB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Installing backend dependencies: started
        Installing backend dependencies: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'done'
      Using cached setuptools-69.0.3-py3-none-any.whl (819 kB)
      Using cached wheel-0.42.0-py3-none-any.whl (65 kB)
      Building wheels for collected packages: pycairo
        Building wheel for pycairo (pyproject.toml): started
        Building wheel for pycairo (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error
      
        × Building wheel for pycairo (pyproject.toml) did not run successfully.
        │ exit code: 1
        ╰─> [15 lines of output]
            running bdist_wheel
            running build
            running build_py
            creating build
            creating build/lib.linux-x86_64-cpython-312
            creating build/lib.linux-x86_64-cpython-312/cairo
            copying cairo/__init__.py -> build/lib.linux-x86_64-cpython-312/cairo
            copying cairo/__init__.pyi -> build/lib.linux-x86_64-cpython-312/cairo
            copying cairo/py.typed -> build/lib.linux-x86_64-cpython-312/cairo
            running build_ext
            Package cairo was not found in the pkg-config search path.
            Perhaps you should add the directory containing `cairo.pc'
            to the PKG_CONFIG_PATH environment variable
            Package 'cairo', required by 'virtual:world', not found
            Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
            [end of output]
      
        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for pycairo
      Failed to build pycairo
      ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
(devbox) 

installing cairo or pycairo doesn't solve it

Steps to reproduce

Create a devbox with the latest version of python and try to install toga through .venv

Command

add, shell

devbox.json

{
  "packages": [
    "pipx@latest",
    "python@latest",
    "cairo@latest",
    "python312Packages.pycairo@latest"
  ],
  "shell": {
    "init_hook": [
      ". $VENV_DIR/bin/activate"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

Devbox version

0.9.0

Nix version

nix (Nix) 2.18.1

What system does this bug occur on?

Linux (x86-64)

Debug logs

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglinkerRelated to linking (ld, ld.so or dyld)linuxLinux systemspythonSupport for Python, pip, Poetry, etc.x86-64x86-64 systems

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions