When I try matplotlib in Python, it says'cairo.Context'

1. Sudden'cairo.Context'

>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> ax1 = fig.add_subplot(2,2,1)
>>> plt.show()
TypeError: Couldn't find foreign struct converter for 'cairo.Context'

What's this ... I was thinking of drawing a graph and playing ...

2. My environment

Distribution: 4.4.5-1-ARCH Python:Python 3.5.1

3. The solution was known to stackoverflow

There was a similar example in the article Python matplotlib Cairo error, so I was able to solve it easily by following Sole. ..

--First, install python3-pyqt5.

#python3 in the official arch repository-python instead of pyqt5-It is called pyqt5.
sudo pacman -S python-pyqt5

--Check the directory to rewrite matplotlibrc.

>>>import matplotlib
>>>matplotlib.matplotlib_fname()
'/usr/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc'

--Rewrite the item of backend :.

matplotlibrc


# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo
# CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG
# Template.
# You can also deploy your own backend outside of matplotlib by
# referring to the module name (which must be in the PYTHONPATH) as
# 'module://my_backend'.
backend      : qt5agg #I rewrote here. Originally backend: gtk3agg

--And ...

did it. I did it.

Recommended Posts

When I try matplotlib in Python, it says'cairo.Context'
Why can't I install matplotlib in python! !!
I made a Discord bot in Python that translates when it reacts
Try gRPC in Python
Try 9 slices in Python
[Question] What happens when I use% in python?
What I do when imitating embedded go in python
I was able to repeat it in Python: lambda
I want to do something in Python when I finish
I wrote python in Japanese
Try LINE Notify in Python
Attention when os.mkdir in Python
Try implementing Yubaba in Python 3
I understand Python in Japanese!
What I learned in Python
Try to make it using GUI and PyQt in Python
When I try to push with heroku, it doesn't work
When I try to make Apache SSL, it doesn't start.
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
Precautions when using pit in Python
Behavior when listing in Python heapq
Try implementing extension method in python
Try using LevelDB in Python (plyvel)
Let's try Fizz Buzz in Python
Try to calculate Trace in Python
Try PLC register access in Python
I wrote Fizz Buzz in Python
I learned about processes in Python
I can't install scikit-learn in Python
Heatmap with Dendrogram in Python + matplotlib
I wrote the queue in Python
When matplotlib doesn't work with python2.7
I tried Line notification in Python
Try using Leap Motion in Python
The first step in Python Matplotlib
When using regular expressions in Python
When writing a program in Python
I wrote the stack in Python
I get a can't set attribute when using @property in python
Try it when Visual Studio Code can't load a Python module
When specifying multiple keys in python sort
Display LaTeX notation formulas in Python, matplotlib
I put Python 2.7 in Sakura VPS 1GB.
I tried to implement PLSA in Python
Try logging in to qiita with Python
Try using the Wunderlist API in Python
Displaying candlestick charts in Python (matplotlib edition)
Wrangle x Python book I tried it [2]
Try using the Kraken API in Python
Create ScriptableObject in Python when building ADX2
I made a payroll program in Python!
Precautions when pickling a function in python
Try working with binary data in Python
Try drawing a simple animation in Python
I tried to implement PLSA in Python 2
Try python
I tried using Bayesian Optimization in Python
I can't debug python scripts in Eclipse
I set the environment variable with Docker and displayed it in Python
When looking at memory usage in Python 3
I implemented Cousera's logistic regression in Python