pygobject pip3 upgrade problem: ERROR: Failed building wheel for pycairo

The problem
This question is cut from a long paragraph and the full text is as follows, it is a problem encountered using pip3 or pip-review upgrade

pygobject==3.34.0 is available (you have 3.26.1)
Defaulting to user installation because normal site-packages is not writeable
Processing /home/thinszx/.cache/pip/wheels/78/4f/f8/35219d6282fc7d90d6713924a12fd05bb0f7eef0fa12bef507/distro_info-0.0.0-py3-none-any.whl
Collecting pygobject==3.34.0
  Using cached PyGObject-3.34.0.tar.gz (699 kB)
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /home/thinszx/.local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-pbwzvrms/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel pycairo
       cwd: None
  Complete output (50 lines):
  Collecting setuptools
    Using cached setuptools-45.2.0-py3-none-any.whl (584 kB)
  Collecting wheel
    Using cached wheel-0.34.2-py2.py3-none-any.whl (26 kB)
  Collecting pycairo
    Using cached pycairo-1.19.0.tar.gz (200 kB)
  Building wheels for collected packages: pycairo
    Building wheel for pycairo (setup.py): started
    Building wheel for pycairo (setup.py): 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-sa57e6b8/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sa57e6b8/pycairo/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-pgit5hrh
         cwd: /tmp/pip-install-sa57e6b8/pycairo/
    Complete output (12 lines):
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/cairo
    copying cairo/__init__.py -> build/lib.linux-x86_64-3.6/cairo
    copying cairo/__init__.pyi -> build/lib.linux-x86_64-3.6/cairo
    copying cairo/py.typed -> build/lib.linux-x86_64-3.6/cairo
    running build_ext
    'pkg-config' not found.
    Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']
    ----------------------------------------
    ERROR: Failed building wheel for pycairo
    Running setup.py clean for pycairo
  Failed to build pycairo
  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-sa57e6b8/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sa57e6b8/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-y2i60oh4/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-pbwzvrms/overlay --compile --install-headers /tmp/pip-build-env-pbwzvrms/overlay/include/python3.6m/pycairo              cwd: /tmp/pip-install-sa57e6b8/pycairo/
      Complete output (12 lines):
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.6
      creating build/lib.linux-x86_64-3.6/cairo
      copying cairo/__init__.py -> build/lib.linux-x86_64-3.6/cairo
      copying cairo/__init__.pyi -> build/lib.linux-x86_64-3.6/cairo
      copying cairo/py.typed -> build/lib.linux-x86_64-3.6/cairo
      running build_ext
      'pkg-config' not found.
      Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sa57e6b8/pycairo/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sa57e6b8/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-y2i60oh4/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-pbwzvrms/overlay --compile --install-headers /tmp/pip-build-env-pbwzvrms/overlay/include/python3.6m/pycairo Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 /home/thinszx/.local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-pbwzvrms/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. 

The solution
As for the package upgrade problem – V2EX, it is said that the PIP or pip3 upgrade will have problems, because the dependency of libgirepository1.0-dev is missing, install

sudo apt-get install libgirepository1.0-dev

And then one less than code>, cario less than /code>

sudo apt-get install python-cairo
sudo apt-get install libcairo2

Read More: