问题遇到的现象和发生背景
python编程从入门到实践的一个例子,总是报错,期初是numpy模块,更新后没有这个问题啦,又开始matplotlib出错,然后也更新到最新版本了,还是出错,求指导解决方法,谢谢~
问题相关代码,请勿粘贴截图
import csv
import matplotlib.pyplot as plt
filename = 'D:/pycharm/LIUJUNJUN/源代码文件/chapter_16/the_csv_file_format/data/sitka_weather_07-2018_simple.csv'
with open(filename) as f:
reader = csv.reader(f)
header_row =next(reader)
highs =[]
for row in reader:
high =int(row[5])
highs.append(high)
print(highs)
for index,column_header in enumerate(header_row):
print(index,column_header)
#根据最高温绘制图形
plt.style.use('seaborn')
fig,ax =plt.subplots()
ax.plot(highs,c ='red')#纵坐标值为highs
#设置图形的格式
ax.set_title('2008年7月每日最高温度',fontsize =24)
ax.set_xlabel('',fontsize =16)
ax.set_ylabel('温度(F)',fontsize = 16)
ax.tick_params(axis='both',which ='major',labelsize =16)
运行结果及报错内容
"D:\Program Files\Anaconda3\python.exe" D:/pycharm/LIUJUNJUN/main.py
Traceback (most recent call last):
File "D:\pycharm\LIUJUNJUN\main.py", line 2, in
import matplotlib.pyplot as plt
File "D:\Program Files\Anaconda3\lib\site-packages\matplotlib_init_.py", line 109, in
from . import _api, _version, cbook, docstring, rcsetup
File "D:\Program Files\Anaconda3\lib\site-packages\matplotlib\rcsetup.py", line 27, in
from matplotlib.colors import Colormap, is_color_like
File "D:\Program Files\Anaconda3\lib\site-packages\matplotlib\colors.py", line 51, in
from PIL import Image
File "D:\Program Files\Anaconda3\lib\site-packages\PIL\Image.py", line 114, in
from . import _imaging as core
ImportError: DLL load failed while importing _imaging: 找不到指定的模块。
进程已结束,退出代码1