import numpy as np
import matplotlib.pyplot as plt #エラー1
x = np.arange(0, 6, 0.1)
y = np.sin(x)
plt.plot(x, y) #エラー2
plt.show()
エラー1の詳細と解決策
※anaconda3以上のディレクトリは消してあります。
エラー発生場所:
import matplotlib.pyplot as plt
エラー内容:
Traceback (most recent call last):
File "", line 1, in
File "/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5agg.py", line 16, in
from .backend_qt5 import QtCore
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 26, in
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 20, in
import matplotlib.backends.qt_editor.formlayout as formlayout
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 56,in
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_compat.py", line 128, in
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
エラー発生場所:
plt.plot(x, y)
エラー内容:
Traceback (most recent call last):
File "", line 1, in
File "/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 3306, in plot
ax = gca()
File "/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 950, in gca
return gcf().gca(**kwargs)
File "/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 586, in gcf
return figure()
File "/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 89, in new_figure_manager_given_figure
window = Tk.Tk()
File "/anaconda3/lib/python3.6/tkinter/__init__.py", line 2017, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable