0

I'm referring this Random Forest Algorithem to predict rejection in different stages.

But I'm getting error while importing matplotlib:

import matplotlib.pyplot as plt

Full Traceback is:

Traceback (most recent call last):
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\backends\backend_cairo.py", line 15, in <module>
import cairo
ModuleNotFoundError: No module named 'cairo'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 3, in <module>
import matplotlib.pyplot as plt
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\pyplot.py", line 2336, in <module>
switch_backend(rcParams["backend"])
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\__init__.py", line 703, in __getitem__
plt.switch_backend(rcsetup._auto_backend_sentinel)
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\pyplot.py", line 256, in switch_backend
switch_backend(candidate)
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\pyplot.py", line 276, in switch_backend
class backend_mod(matplotlib.backend_bases._Backend):
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\pyplot.py", line 277, in backend_mod
locals().update(vars(importlib.import_module(backend_name)))
File "C:\workspace\Python\venv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\backends\backend_gtk3agg.py", line 5, in <module>
from . import backend_cairo
File "C:\workspace\Python\venv\lib\site-packages\matplotlib\backends\backend_cairo.py", line 22, in <module>
import cairocffi as cairo
File "C:\workspace\Python\venv\lib\site-packages\cairocffi\__init__.py", line 39, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2', 'cairo.so.2')
File "C:\workspace\Python\venv\lib\site-packages\cairocffi\__init__.py", line 36, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2

Please guide me where I'm doing mistake.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Anil Jagtap
  • 1,740
  • 4
  • 27
  • 44
  • 1
    It should be obvious that this is a `matplotlib` question, has nothing to do with `machine-learning`, `scikit-learn`, or `random-forest`, and all the posted code except `import matplotlib.pyplot as plt` is irrelevant to the issue and hence should not be posted here (edited). – desertnaut Oct 06 '20 at 10:51
  • Try doing a google search on 'matplotlib caiiro import error', it should provide 4 or 5 stackOverflow recommendations for resolving this issue. – itprorh66 Oct 06 '20 at 12:25
  • [enter link description here](https://stackoverflow.com/questions/37437041/dlopen-failed-to-load-a-library-cairo-cairo-2) maybe this will help you. – orel museri Oct 31 '21 at 09:38

0 Answers0