Python下载以及安装matplotlib
下载Python
安装matplotlib
测试
下载Python
下载Python官网入口:https://www.python.org/
-
点击Doenloads->Windows
-
点击Stable Releases(稳定版)下面的Python1.8.1-Dec.18,2019
-
选择window x86-64 executable installer下载
-
勾选Add Python 3.8 to PATH,点击Customize installation进行Python安装
-
勾选安装完毕后会自动加入环境路径中,如图第一第二行所示:
安装matplotlib
由于试过cmd等多个网上安装教程都报错,最终我选择暴力安装法
-
通过网页下载Matplotlib,网页下载Matplotlib入口点击左边的Download Files选择对应版本
-
由于我下的是2020最新版3.8.1版本,所以我有一下选择:
cp38表示版本,python3.8就选择cp38;win-amd64对应的win64;
我选择了第三个matplotlib-3.1.3-cp38-win_amd64.whl -
再安装matplotlib时需要先安装
six cycler dateutil pytz pyparsing numpy kiwisolver 等模块,再安装matplotlib时就会成功了;
这几个模块在该入口均能搜索到,例如:
最终下载的模块有:
(上图python文件下载python时就有的,不用自己下载)
把这些模块移入scripts文件夹下:
- 打开cmd命令行
在你保存的python根目录下:cd python\scripts进入scripts目录下输入python -m pip install six-1.14.0-py2.py3-none-any.whl回车安装six模块
安装的顺序是six cycler dateutil pytz pyparsing numpy kiwisolve,z只需要更改上边黄色部分文件的名称进行安装即可,最后安装matplotilb
测试
打开IDLE(python 3.8.64-bit)
输入以下代码:
值得注意的是,不能直接一整个复制粘贴过去,会报错,需要一行行的,因为python需要换行
import matplotlib.pyplot as plt
labels='frogs','hogs','dogs','logs'
sizes=15,20,45,10
colors='yellowgreen','gold','lightskyblue','lightcoral'
explode=0,0.1,0,0
plt.pie(sizes,explode=explode,labels=labels,colors=colors,autopct='%1.1f%%',shadow=True,startangle=50)
plt.axis('equal')
plt.show()
效果:
matplotlib案例官网入口