Numpy、SciPy、MatplotLib是Python下从事科学计算必不可少的库。我在用其他的方法安装时出现各种问题,发现直接安装.whl包是最快且不报错的方法。

1.下载.whl包
在下面的网站中找需要的.whl文件下载
http://www.lfd.uci.edu/~gohlke/pythonlibs/
要和自己本地安装的版本一致,我选择的whl文件是:
numpy-1.13.0+mkl-cp36-cp36m-win32.whl
scipy-0.19.1-cp36-cp36m-win32.whl
matplotlib-2.0.2-cp36-cp36m-win32.whl

2.开始在命令行安装
>pip3 install c:\(whl文件下载的路径)\numpy-1.13.0+mkl-cp36-cp36m-win32.whl
>pip3 install c:\(whl文件下载的路径)\scipy-0.19.1-cp36-cp36m-win32.whl
>pip3 install c:\(whl文件下载的路径)\matplotlib-2.0.2-cp36-cp36m-win32.whl

如果不出意外,这就都安装好了。

3.开始测试
测试代码来自:http://www.cnblogs.com/jasonfreak/p/5441512.html 感谢作者

 from numpy import array
from numpy.random import normal
from matplotlib import pyplot def genData():
heights = []
weights = []
grades = []
N = 10000 for i in range(N):
while True:
# 身高服从均值172,标准差为6的正态分布
height = normal(172, 6)
if 0 < height: break
while True:
# 体重由身高作为自变量的线性回归模型产生,误差服从标准正态分布
weight = (height - 80) * 0.7 + normal(0, 1)
if 0 < weight: break
while True:
# 分数服从均值为70,标准差为15的正态分布
score = normal(70, 15)
if 0 <= score and score <= 100:
grade = 'E' if score < 60 else (
'D' if score < 70 else ('C' if score < 80 else ('B' if score < 90 else 'A')))
break
heights.append(height)
weights.append(weight)
grades.append(grade)
return array(heights), array(weights), array(grades) # 绘制柱状图
def drawBar(grades):
xticks = ['A', 'B', 'C', 'D', 'E']
gradeGroup = {}
# 对每一类成绩进行频数统计
for grade in grades:
gradeGroup[grade] = gradeGroup.get(grade, 0) + 1
# 创建柱状图
# 第一个参数为柱的横坐标
# 第二个参数为柱的高度
# 参数align为柱的对齐方式,以第一个参数为参考标准
pyplot.bar(range(5), [gradeGroup.get(xtick, 0) for xtick in xticks], align='center') # 设置柱的文字说明
# 第一个参数为文字说明的横坐标
# 第二个参数为文字说明的内容
pyplot.xticks(range(5), xticks) # 设置横坐标的文字说明
pyplot.xlabel('Grade')
# 设置纵坐标的文字说明
pyplot.ylabel('Frequency')
# 设置标题
pyplot.title('Grades Of Male Students')
# 绘图
pyplot.show() #绘制饼形图
def drawPie(grades):
labels = ['A', 'B', 'C', 'D', 'E']
gradeGroup = {}
for grade in grades:
gradeGroup[grade] = gradeGroup.get(grade, 0) + 1
#创建饼形图
#第一个参数为扇形的面积
#labels参数为扇形的说明文字
#autopct参数为扇形占比的显示格式
pyplot.pie([gradeGroup.get(label, 0) for label in labels], labels=labels, autopct='%1.1f%%')
pyplot.title('Grades Of Male Students')
pyplot.show() #绘制直方图
def drawHist(heights):
#创建直方图
#第一个参数为待绘制的定量数据,不同于定性数据,这里并没有事先进行频数统计
#第二个参数为划分的区间个数
pyplot.hist(heights, 100)
pyplot.xlabel('Heights')
pyplot.ylabel('Frequency')
pyplot.title('Heights Of Male Students')
pyplot.show() #绘制累积曲线
def drawCumulativeHist(heights):
#创建累积曲线
#第一个参数为待绘制的定量数据
#第二个参数为划分的区间个数
#normed参数为是否无量纲化
#histtype参数为'step',绘制阶梯状的曲线
#cumulative参数为是否累积
pyplot.hist(heights, 20, normed=True, histtype='step', cumulative=True)
pyplot.xlabel('Heights')
pyplot.ylabel('Frequency')
pyplot.title('Heights Of Male Students')
pyplot.show() #绘制散点图
def drawScatter(heights, weights):
#创建散点图
#第一个参数为点的横坐标
#第二个参数为点的纵坐标
pyplot.scatter(heights, weights)
pyplot.xlabel('Heights')
pyplot.ylabel('Weights')
pyplot.title('Heights & Weights Of Male Students')
pyplot.show() #绘制箱形图
def drawBox(heights):
#创建箱形图
#第一个参数为待绘制的定量数据
#第二个参数为数据的文字说明
pyplot.boxplot([heights], labels=['Heights'])
pyplot.title('Heights Of Male Students')
pyplot.show() data = genData()
print(data)
heights = data[0]
weights = data[1]
grades = data[2]
drawBar(grades)
drawPie(grades)
drawHist(heights)
drawCumulativeHist(heights)
drawScatter(heights, weights)
drawBox(heights)

运行结果:

drawBar(grades)

drawPie(grades)

drawHist(heights)

drawCumulativeHist(heights)

drawScatter(heights, weights)

drawBox(heights)

成功!

Windows10+Python3下安装NumPy+SciPy+Matplotlib的更多相关文章

  1. Ubuntu下安装Numpy, SciPy and Matplotlib

    Python开发环境包含科学计算,需要安装NumPy, SciPy, Matplotlib.其中Matplotlib依赖于Python和NumPy.我们先安装NumPY和SciPy.  Matplot ...

  2. Linux入门(10)——Ubuntu16.04使用pip3和pip安装numpy,scipy,matplotlib等第三方库

    安装Python3第三方库numpy,scipy,matplotlib: sudo apt install python3-pip pip3 install numpy pip3 install sc ...

  3. win7 64+python2.7.12安装numpy+scipy+matplotlib+scikit-learn

    python包下载网址 http://www.lfd.uci.edu/~gohlke/pythonlibs/ 1.已经安装python2.7.12,查看scripts里是否有pip.2.7.9版本以上 ...

  4. mac安装numpy,scipy,matplotlib

      SaintKings-Mac-mini:~ saintking$ python Python ( , ::) [GCC Compatible Apple LLVM (clang-)] on dar ...

  5. ubuntu下安装numpy和matplotlib

    安装NumPy函数库--sudo apt-get install python-numpy 以及  sudo apt-get install python-scipy NumPy函数库的函数查看:Nu ...

  6. Python中安装numpy,scipy,matplotlib安装方法

    这个吧,说简单也简单,说难吧我捣鼓了两天才弄出来,真是头发都急白了.其实只要一个网址就搞定了,嘿嘿 http://www.lfd.uci.edu 这里面有你需要的任何东西,当你运行python imp ...

  7. Python: Ubuntu 安装numpy,scipy,matplotlib

    安装python-dev 安装这个包,以后安装各种python扩展包,可以省很多事情. sudo apt-get install python-dev 使用apt-get 安装 只需要下面的几个命令即 ...

  8. windows 安装 numpy scipy matplotlib scikit-learn

    直接使用  pip install 包名  的方法安装不成功 下载第三方安装包 下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy  根据系统 ...

  9. win7系统下python安装numpy,matplotlib,scipy和scikit-learn

    1.安装numpy,matplotlib,scipy和scikit-learn win7系统下直接采用pip或者下载源文件进行安装numpy,matplotlib,scipy时会遇到各种问题,这是因为 ...

随机推荐

  1. MySQL修改编码设置及乱码问题

    源地址:http://blog.csdn.net/millia/article/details/5806774   昨天尝试把自己用php编写的第一个糙站发布到网上..结果出现了因为编码不统一而导致乱 ...

  2. SQL Server - 最佳实践 - 参数嗅探问题 转。

    文章来自:https://yq.aliyun.com/articles/61767 先说我的问题,最近某个存储过程,暂定名字:sp_a 总是执行超时,sp_a带有一个参数,暂定名为 para1 var ...

  3. python 刷题必备

    1.判断输入的数字是否是回文数: 学习内容:把数字转成字符串 1. def is_palindrome(n): n=str(n) m=n[::-1] return n==m 2. tmp_str = ...

  4. Windows驱动手动卸载与安装

    彻底卸载的流程 1.删除C:\windows\inf\oem.inf路径下的所有oem文件 2.删除c:\windows\system32\drivers路径下对应的sys文件 3.(重要) 第一步: ...

  5. ECMAScript6新特性之Array API

    一 填充数组 var arr = new Array(5); arr.fill('abc',2,4); console.log('Array.prototype.fill',arr); // [und ...

  6. 【转】HttpHandler的认识与加深理解

    原文:http://www.cnblogs.com/whtydn/archive/2009/10/19/1585778.html HttpHandler是HTTP请求的处理中心,真正地对客户端请求的服 ...

  7. PM2使用及介绍

    pm2 是一个带有负载均衡功能的Node应用的进程管理器.当你要把你的独立代码利用全部的服务器上的所有CPU,并保证进程永远都活着,0秒的重载, PM2是完美的.它非常适合IaaS结构,但不要把它用于 ...

  8. Tornado异步阻塞解决方案

    在 tornado 中异步无阻塞的执行耗时任务 在 linux 上 tornado 是基于 epoll 的事件驱动框架,在网络事件上是无阻塞的.但是因为 tornado 自身是单线程的,所以如果我们在 ...

  9. mysql contact_ws函数 字符串被截断问题

    contact函数默认有字符串长度限制,解决方法:SET group_concat_max_len = 20000这个参数设置一下就好了

  10. 关于前一篇innodb自增列自己的一点补充

    上篇文章是我转载的,忘记注明了出处,在这里深感歉意.但是上篇文章中关于自增列预留ID的计算我当时怎么弄明白,后来自己想了想终于想通了,在这里详细解释一下. 我们以一次性插入10行为例,表格如下:  插 ...