TaylorSMarks / playsound

Pure Python, cross platform, single function module with no dependencies for playing sounds.
Other
504 stars 118 forks source link

[BUG]: Playsound[pygoobject] not working on Ubuntu due to third party requirements. #124

Open lafftar opened 2 years ago

lafftar commented 2 years ago

My uname -a: Linux lafftar 5.13.0-44-generic #49-Ubuntu SMP Wed May 18 13:28:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

My py -V: Python 3.10.0

I'm trying to fix this warning: playsound is relying on another python subprocess. Please use 'pip install pygobject' if you want playsound to run more efficiently.

I run pip install pygobject, and am greeted with this error:

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
        ╰─> [9 lines of output]
            running bdist_wheel
            running build
            running build_py
            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
            No package 'cairo' found
            Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
            [end of output]

As you can see, the error is initated when building wheels for pycairo: No package 'cairo' found. I went to install pycairo with pip install pycario, and got this error:

Building wheels for collected packages: pycairo
  Building wheel for pycairo (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pycairo (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      running bdist_wheel
      running build
      running build_py
      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
      No package 'cairo' found
      Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
      [end of output]

I went investigating and stumbled on https://github.com/pygobject/pycairo/issues/212#issuecomment-772429007, There are no wheels for pycairo outside of windows sadly.. Do i really have to compile a third party package in order to use playsound?

seapagan commented 2 years ago

I got this working properly under Ubuntu 22.04, it's not too much of a hassle. You need to install a few Ubuntu deps first, as noted on the pycairo webpages:

sudo apt install libcairo2-dev pkg-config python3-dev

You can then install the pycairo package :

pip install pycairo

There is one more dependency that is required (on my system at least) to install pygobject properly:

sudo apt install libgirepository1.0-dev

After all this, pygobject should just install fine:

pip install pygobject
haopXpycary commented 1 year ago

My uname -a:Linux DESKTOP-GF8JR20 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux My py -v: Python 3.10.6 I set up the environment according to the above command.And i pip pygobject and pycario successfully.

$ **pip3 install pygobject**
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pygobject in /usr/lib/python3/dist-packages (3.42.1)
Requirement already satisfied: pycairo>=1.16.0 in /usr/lib/python3/dist-packages (from pygobject) (1.20.1)
$ **pip3 install pycairo**
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pycairo in /usr/lib/python3/dist-packages (1.20.1)

But when I try to run

$ **python3 main.py**
playsound is relying on another python subprocess. Please use `pip install pygobject` if you want playsound to run more efficiently.

I don't know what went wrong