Ubuntu下安装Numpy, SciPy and Matplotlib

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

1.首先确保你的apt-get可用。如果不可用 试着更新一下

sudo apt-get install

2.安装你的NumPy和SciPy.

apt-get install python-numpy
apt-get install python-scipy

3.安装你的Matplotlib

安装Matplotlib前需要先安装其依赖的包libpng和freetype
安装libpng:

sudo apt-get install libpng-dev

安装freetype:

首先需要从网上下载freetype文件:http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz

下载成功后可以选择安装地址(笔者安装在 /usr/local/freetype 下)

sudo mkdir /usr/local/freetype
sudo cp freetype-2.4.10.tar.gz  /usr/local/freetype
sudo tar zxvf freetype-2.4.10.tar.gz
sudo cd freetype-2.4.10/
sudo ./congfigure
sudo make
sudo make install 

如果在执行sudo mke install时出现错误

rm -f /usr/local/modules/freetype/include/freetype2/freetype/cache/*
rmdir /usr/local/modules/freetype/include/freetype2/freetype/cache
rm -f /usr/local/modules/freetype/include/freetype2/freetype/internal/*
rmdir /usr/local/modules/freetype/include/freetype2/freetype/internal
rmdir: ‘/usr/local/modules/freetype/include/freetype2/freetype/internal’: 没有那个文件或目录
make: [install错误 1 (忽略)
/usr/bin/install -c -m 644 ./builds/unix/ft2unix.h \
/usr/local/modules/freetype/include/ft2build.h
/usr/bin/install -c -m 644 ./builds/unix/ftconfig.h                        \
/usr/local/modules/freetype/include/freetype2/freetype/config/ftconfig.h
/usr/bin/install -c -m 644 /opt/src/lamp/freetype-2.2.1/objs/ftmodule.h                          \
/usr/local/modules/freetype/include/freetype2/freetype/config/ftmodule.h
/usr/bin/install -c -m 755 ./builds/unix/freetype-config \
/usr/local/modules/freetype/bin/freetype-config
/usr/bin/install -c -m 644 ./builds/unix/freetype2.m4 \
/usr/local/modules/freetype/share/aclocal/freetype2.m4
/usr/bin/install -c -m 644 ./builds/unix/freetype2.pc \
/usr/local/modules/freetype/lib/pkgconfig/freetype2.pc
注意上面的黑体字“rmdir: ‘/usr/local/modules/freetype/include/freetype2/freetype/internal’: 没有那个文件或目录 make: [install错误 1 (忽略)” (不同用户可能又不同路径)
解决方法:
sudo mkdir rmdir: /usr/local/modules/freetype/include/freetype2/freetype/internal

  之后重新尝试sudo make install方法。

安装pip,然后通过pip来安装matplotlib:

sudo apt-get install python-pip

 

安装好pip后就可以用下面的命令来查找matplotlib和查看其安装状态

sudo pip search matplotlib

 

安装matplotlib

sudo pip install matplotlib

 

 

OK现在来检验一下

eric@eric-Lenovo-Y50-70:~$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy import *
>>> random.rand(4,4)
array([[ 0.9615149 ,  0.8125032 ,  0.39732582,  0.31623145],
       [ 0.72705913,  0.58407689,  0.81894134,  0.78653881],
       [ 0.20863496,  0.08460187,  0.35620451,  0.49642794],
       [ 0.34755404,  0.366561  ,  0.2603963 ,  0.85014281]])
>>> exit()
eric@eric-Lenovo-Y50-70:~$ 

注意random.ran(4,4)为随机生成一个4×4数组,数组元素为随机数

 

转载于:https://www.cnblogs.com/gzp2015/p/4623827.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值