Python3 cannot install notify-send

1.1k Views Asked by At

For Linux Mint 18.3 32-bit and Python 3.5.2 plus a Python3 virtual environment.

I'm having trouble installing Python 3's notify-send. The objective being to display text in a "notification bubble" ala:

notify-send in Linux Mint 18.3 via BASH script

I already have a BASH script that does what I want. I was hoping to replicate that directly in Python3 rather than resort to a subprocess that invokes BASH's command line instance of notify-send.

  1. I created a folder for a Python 3 virtual environment, in that folder used python3 -m venv gui_experiments to create the virtual environment, then used source env/gui_experiments/activateto activate that venv. Received the prompt that characterizes an active venv...

  2. In that virtual environment, pip informed me that I should upgrade pip. The upgraded version already existed outside the virtual environment but not within it. When in the venv I tried to use the command line suggested by pip -- sudo -H pip install --upgrade pip -- pip informed me the most current version was already installed. To break the upgrade->already-installed loop I instead used python3 -m pip3 install --upgrade pip3 to force pip to upgrade to version 19.3.1 (current as of this date).

  3. pip search notify-send | grep ^notify-send returns:

    notify-send (0.0.13)

  4. Typed sudo -H python3 -m pip install notify-send. Lengthy error message ==

    rbv@rbv-F80Q ~/PythonLessons/gui_experiments $ sudo -H python3 -m pip install notify-send
    Collecting notify-send
      Using cached https://files.pythonhosted.org/packages/d1/e7/e495fda6524db0c59f3a4db05e3a54b96eae9afe4436d921dda3a7cb60ab/notify_send-0.0.13-py3-none-any.whl
    Collecting pycairo>=1.18.1; sys_platform == "linux"
      Using cached https://files.pythonhosted.org/packages/48/20/5e83af98eb897935bf7dc39455e892ba866feebb9b7c3b392982866f9958/pycairo-1.18.1.tar.gz
    Collecting PyGObject>=3.34.0; sys_platform == "linux"
      Using cached https://files.pythonhosted.org/packages/46/8a/b183f3edc812d4d28c8b671a922b5bc2863be5d38c56b3ad9155815e78dd/PyGObject-3.34.0.tar.gz
      Installing build dependencies ... error
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 /usr/local/lib/python3.5/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-oxsfyhvu/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo
           cwd: None
      Complete output (30 lines):
      Collecting setuptools
        Using cached https://files.pythonhosted.org/packages/6a/9a/50fadfd53ec909e4399b67c74cc7f4e883488035cfcdb90b685758fa8b34/setuptools-41.4.0-py2.py3-none-any.whl
      Collecting wheel
        Using cached https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl
      Collecting pycairo
        Using cached https://files.pythonhosted.org/packages/48/20/5e83af98eb897935bf7dc39455e892ba866feebb9b7c3b392982866f9958/pycairo-1.18.1.tar.gz
      Installing collected packages: setuptools, wheel, pycairo
          Running setup.py install for pycairo: started
          Running setup.py install for pycairo: finished with status 'error'
          ERROR: Command errored out with exit status 1:
           command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-x0kren5a/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-x0kren5a/pycairo/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-h73tgq7k/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-oxsfyhvu/overlay --compile
               cwd: /tmp/pip-install-x0kren5a/pycairo/
          Complete output (15 lines):
          running install
          running build
          running build_py
          creating build
          creating build/lib.linux-i686-3.5
          creating build/lib.linux-i686-3.5/cairo
          copying cairo/__init__.py -> build/lib.linux-i686-3.5/cairo
          copying cairo/__init__.pyi -> build/lib.linux-i686-3.5/cairo
          copying cairo/py.typed -> build/lib.linux-i686-3.5/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
          No package 'cairo' found
          Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']' returned non-zero exit status 1
          ----------------------------------------
      ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-x0kren5a/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-x0kren5a/pycairo/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-h73tgq7k/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-oxsfyhvu/overlay --compile Check the logs for full command output.
      ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.5/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-oxsfyhvu/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo Check the logs for full command output.
    (gui_experiments) 
    rbv@rbv-F80Q ~/PythonLessons/gui_experiments $ 
  1. It seemed like pycairo might be the issue. But synaptic lists python3-cairo as installed. So I tried sudo -H pip install pycairo. Error message ==
    Collecting pycairo
      Using cached https://files.pythonhosted.org/packages/48/20/5e83af98eb897935bf7dc39455e892ba866feebb9b7c3b392982866f9958/pycairo-1.18.1.tar.gz
    Installing collected packages: pycairo
        Running setup.py install for pycairo ... error
        ERROR: Command errored out with exit status 1:
         command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t3zwxfq6/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t3zwxfq6/pycairo/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-8mfgxfm6/install-record.txt --single-version-externally-managed --compile
             cwd: /tmp/pip-install-t3zwxfq6/pycairo/
        Complete output (15 lines):
        running install
        running build
        running build_py
        creating build
        creating build/lib.linux-i686-3.5
        creating build/lib.linux-i686-3.5/cairo
        copying cairo/__init__.py -> build/lib.linux-i686-3.5/cairo
        copying cairo/__init__.pyi -> build/lib.linux-i686-3.5/cairo
        copying cairo/py.typed -> build/lib.linux-i686-3.5/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
        No package 'cairo' found
        Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']' returned non-zero exit status 1
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t3zwxfq6/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t3zwxfq6/pycairo/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-8mfgxfm6/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
  1. Tried repeating those steps after deactivating the virtual environment and changing to a different directory. Same problems.

At this point I'm stumped. I don't understand some of the error messages (for example Perhaps you should add the directory containing `cairo.pc').

I've never had this many difficulties, or lengthy error messages, using pip or python3 -m to install libraries.

I'm wondering if the problems arise because I'm running 32-bit Linux?

1

There are 1 best solutions below

3
On

Install the cairo package, pycairo is only an interface to cairo, not the library itself. Check the docs for installation, but of these should do it:

For Debian and Debian derivatives including Ubuntu:

sudo apt-get install libcairo2-dev

For Fedora:

sudo yum install cairo-devel

For openSUSE:

zypper install cairo-devel