pygobject/pycairo

"pip install pycairo" gives error on WSL Ubuntu 22.04.5 LTS

Closed this issue · 4 comments

Hello,

I have the nwest Ubuntu 22.04.5 LTS on my WSL. Can not install pycairo using pip - any help, please ?

pip install pycairo
Defaulting to user installation because normal site-packages is not writeable
Collecting pycairo
  Using cached pycairo-1.27.0.tar.gz (661 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
          hook = backend.prepare_metadata_for_build_wheel
      AttributeError: module 'mesonpy' has no attribute 'prepare_metadata_for_build_wheel'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
        File "/tmp/pip-build-env-ie4yot7l/overlay/local/lib/python3.10/dist-packages/mesonpy/__init__.py", line 1020, in wrapper
          return func(*args, **kwargs)
        File "/tmp/pip-build-env-ie4yot7l/overlay/local/lib/python3.10/dist-packages/mesonpy/__init__.py", line 1073, in build_wheel
          with _project(config_settings) as project:
        File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
          return next(self.gen)
        File "/tmp/pip-build-env-ie4yot7l/overlay/local/lib/python3.10/dist-packages/mesonpy/__init__.py", line 947, in _project
          yield Project(source_dir, build_dir, meson_args, editable_verbose)
        File "/tmp/pip-build-env-ie4yot7l/overlay/local/lib/python3.10/dist-packages/mesonpy/__init__.py", line 662, in __init__
          self._meson = _get_meson_command(pyproject_config.get('meson'))
        File "/tmp/pip-build-env-ie4yot7l/overlay/local/lib/python3.10/dist-packages/mesonpy/__init__.py", line 982, in _get_meson_command
          meson_version = subprocess.run(cmd + ['--version'], check=False, text=True, capture_output=True).stdout
        File "/usr/lib/python3.10/subprocess.py", line 503, in run
          with Popen(*popenargs, **kwargs) as process:
        File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
          self._execute_child(args, executable, preexec_fn, close_fds,
        File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
          raise child_exception_type(errno_num, err_msg, err_filename)
      FileNotFoundError: [Errno 2] No such file or directory: 'meson'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Ok, "sudo apt install meson" helped partially, but it needs higher version of meson ...

pip install pycairo
Defaulting to user installation because normal site-packages is not writeable
Collecting pycairo
  Using cached pycairo-1.27.0.tar.gz (661 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [3 lines of output]

      meson-python: error: Could not find meson version 0.63.3 or newer, found 0.61.2
      meson-python: error: .
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

well, after installing meson via pip, and other packages, I am getting a new error:

pip install pycairo
Defaulting to user installation because normal site-packages is not writeable
Collecting pycairo
  Using cached pycairo-1.27.0.tar.gz (661 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [48 lines of output]
      + meson setup /tmp/pip-install-qa8pt8g6/pycairo_02558d502fcc432a968e14f11180770b /tmp/pip-install-qa8pt8g6/pycairo_02558d502fcc432a968e14f11180770b/.mesonpy-ds0q2lp1 -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dwheel=true -Dtests=false --native-file=/tmp/pip-install-qa8pt8g6/pycairo_02558d502fcc432a968e14f11180770b/.mesonpy-ds0q2lp1/meson-python-native-file.ini
      The Meson build system
      Version: 1.5.2
      Source dir: /tmp/pip-install-qa8pt8g6/pycairo_02558d502fcc432a968e14f11180770b
      Build dir: /tmp/pip-install-qa8pt8g6/pycairo_02558d502fcc432a968e14f11180770b/.mesonpy-ds0q2lp1
      Build type: native build
      Project name: pycairo
      Project version: 1.27.0
      C compiler for the host machine: cc (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
      C linker for the host machine: cc ld.bfd 2.38
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Program python3 found: YES (/usr/bin/python3)
      Compiler for C supports arguments -Wall: YES
      Compiler for C supports arguments -Warray-bounds: YES
      Compiler for C supports arguments -Wcast-align: YES
      Compiler for C supports arguments -Wconversion: YES
      Compiler for C supports arguments -Wextra: YES
      Compiler for C supports arguments -Wformat=2: YES
      Compiler for C supports arguments -Wformat-nonliteral: YES
      Compiler for C supports arguments -Wformat-security: YES
      Compiler for C supports arguments -Wimplicit-function-declaration: YES
      Compiler for C supports arguments -Winit-self: YES
      Compiler for C supports arguments -Winline: YES
      Compiler for C supports arguments -Wmissing-format-attribute: YES
      Compiler for C supports arguments -Wmissing-noreturn: YES
      Compiler for C supports arguments -Wnested-externs: YES
      Compiler for C supports arguments -Wold-style-definition: YES
      Compiler for C supports arguments -Wpacked: YES
      Compiler for C supports arguments -Wpointer-arith: YES
      Compiler for C supports arguments -Wreturn-type: YES
      Compiler for C supports arguments -Wshadow: YES
      Compiler for C supports arguments -Wsign-compare: YES
      Compiler for C supports arguments -Wstrict-aliasing: YES
      Compiler for C supports arguments -Wundef: YES
      Compiler for C supports arguments -Wunused-but-set-variable: YES
      Compiler for C supports arguments -Wswitch-default: YES
      Compiler for C supports arguments -Wno-missing-field-initializers: YES
      Compiler for C supports arguments -Wno-unused-parameter: YES
      Compiler for C supports arguments -fno-strict-aliasing: YES
      Compiler for C supports arguments -fvisibility=hidden: YES
      Found pkg-config: YES (/usr/bin/pkg-config) 1.8.0
      Found CMake: /usr/bin/cmake (3.22.1)
      Run-time dependency cairo found: NO (tried pkgconfig and cmake)

      ../cairo/meson.build:31:12: ERROR: Dependency "cairo" not found, tried pkgconfig and cmake

      A full log can be found at /tmp/pip-install-qa8pt8g6/pycairo_02558d502fcc432a968e14f11180770b/.mesonpy-ds0q2lp1/meson-logs/meson-log.txt
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

You need sudo apt install libcairo2-dev pkg-config python3-dev, see https://pycairo.readthedocs.io/en/latest/getting_started.html

The first issue you solved was #384

Thanks ! Fixed, closing this issue.