Saturday, 6 February 2021

installing pycairo in Ubuntu 16

I want to execute matplotlib.pyplot in python. I'm using python in my terminal whose version is 3.7.9. I use a text editor to write my code and terminal to execute that code My code :

>>> import matplotlib.pyplot as p
>>> p.plot((1,2,3),(1,4,9))
[<matplotlib.lines.Line2D object at 0xb2da6a6c>]
>>> p.show()
__main__:1: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

Hence I want to use matplotlib.use('GTK3Agg') in my code

>>> import matplotlib as m
>>> m.use('GKT3Agg')
>>> import matplotlib.pyplot as p

ModuleNotFoundError: No module named 'cairo._cairo'

During handling of the above exception, another exception occurred:

ModuleNotFoundError: No module named 'cairocffi'

The above exception was the direct cause of the following exception:

ImportError: cairo backend requires that pycairo>=1.11.0 or cairocffiis installed

The above exception was the direct cause of the following exception:

ImportError: backend Gtk3Agg requires cairo

Hence, I tried installing pycairo usng pip

$ pip install pycairo
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting pycairo
  Using cached pycairo-1.19.1.tar.gz (205 kB)
Building wheels for collected packages: pycairo
  Building wheel for pycairo (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3.5 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/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-1j4p8bnw
       cwd: /tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/
  Complete output (17 lines):
  /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
    warnings.warn(msg)
  running bdist_wheel
  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: Failed building wheel for pycairo
  Running setup.py clean for pycairo
Failed to build pycairo
Installing collected packages: pycairo
    Running setup.py install for pycairo ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.5 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/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-jhm7vk06/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/root/.local/include/python3.5m/pycairo
         cwd: /tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/
    Complete output (17 lines):
    /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    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.5 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1u768g_b/pycairo_129df67acbc44492bbbbd32f7aab07c8/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-jhm7vk06/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/root/.local/include/python3.5m/pycairo Check the logs for full command output.

EDIT AGAIN:

$ sudo apt install libcairo2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libcairo2 is already the newest version (1.14.6-1).
0 upgraded, 0 newly installed, 0 to remove and 396 not upgraded.

$ pip install pycairo
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting pycairo
  Using cached pycairo-1.19.1.tar.gz (205 kB)
Building wheels for collected packages: pycairo
  Building wheel for pycairo (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3.5 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/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-m_8eywvf
       cwd: /tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/
  Complete output (17 lines):
  /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
    warnings.warn(msg)
  running bdist_wheel
  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: Failed building wheel for pycairo
  Running setup.py clean for pycairo
Failed to build pycairo
Installing collected packages: pycairo
    Running setup.py install for pycairo ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.5 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/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-k9fb582b/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/user1/.local/include/python3.5m/pycairo
         cwd: /tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/
    Complete output (17 lines):
    /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    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.5 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7v8ml56w/pycairo_9596398ddd97435282ebfa5f81118863/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-k9fb582b/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/userr1/.local/include/python3.5m/pycairo Check the logs for full command output.
WARNING: You are using pip version 20.3.3; however, version 20.3.4 is available.
You should consider upgrading via the '/usr/bin/python3.5 -m pip install --upgrade pip' command.

What else shall I do to use matplotlib in my terminal???



from installing pycairo in Ubuntu 16

No comments:

Post a Comment