前提・実現したいこと
Pythonを学習し始めたばかりの初心者です。
matplotlibをインポートしたはずなのに使えません。
発生している問題・エラーメッセージ
error
1Traceback (most recent call last): 2 File "<input>", line 1, in <module> 3 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 198, in runfile 4 pydev_imports.execfile(filename, global_vars, local_vars) # execute the script 5 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile 6 exec(compile(contents+"\n", file, 'exec'), glob, loc) 7 File "C:/Users/zhang/PycharmProjects/pythonProject1/aaa.py", line 1, in <module> 8 import matplotlib.pyplot as plt 9 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import 10 module = self._system_import(name, *args, **kwargs) 11 File "C:\Users\zhang\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\pyplot.py", line 36, in <module> 12 import matplotlib.colorbar 13 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import 14 module = self._system_import(name, *args, **kwargs) 15 File "C:\Users\zhang\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\colorbar.py", line 44, in <module> 16 import matplotlib.contour as contour 17 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import 18 module = self._system_import(name, *args, **kwargs) 19 File "C:\Users\zhang\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\contour.py", line 17, in <module> 20 import matplotlib.text as text 21 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import 22 module = self._system_import(name, *args, **kwargs) 23 File "C:\Users\zhang\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\text.py", line 16, in <module> 24 from .textpath import TextPath # Unused, but imported by others. 25 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import 26 module = self._system_import(name, *args, **kwargs) 27 File "C:\Users\zhang\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\textpath.py", line 11, in <module> 28 from matplotlib.mathtext import MathTextParser 29 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import 30 module = self._system_import(name, *args, **kwargs) 31 File "C:\Users\zhang\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\mathtext.py", line 27, in <module> 32 from PIL import Image 33 File "D:\Program Files\JetBrains\PyCharm 2021.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import 34 module = self._system_import(name, *args, **kwargs) 35ModuleNotFoundError: No module named 'PIL' 36
というエラーが出ました以下がソースコードです
該当のソースコード
python
1import matplotlib.pyplot as plt 2import numpy as np 3a=[1228.3,1600.38,653.8,760.07,1500.16,1896.18] 4month = np.arange(1,7) 5plt.rcParams['font.sans-serif']=['SimHei'] 6plt.rcParams['axes.unicode_minus']=False 7plt.rcParams["font.size"] = 15 8plt.plot(month,a,"r:D") 9plt.title("title",fontsize = 25, color = 'red') 10plt.xlabel("x") 11plt.ylabel("y") 12plt.show() 13
試したこと
バージョンを落としたりしましたが、やはりできませんでした
補足情報(FW/ツールのバージョンなど)
pycharm2021 2月
python 3.9
matplotlib:3.3.0
numpy:1.21.2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/09/06 01:44