一,安装步骤
NumPy函数库是Python开发环境下的一个独立的模块。
1.下载源码包:
wget http://jaist.dl.sourceforge.net/project/numpy/NumPy/1.9.0/numpy-1.9.0.zip
2.解压
unzip numpy-1.9.0.zip
3.进入解压目录
cd numpy-1.9.0
4.运行解压目录里的setup.py 文件(一定要在root环境下安装!!!!)
python setup.py install
二,安装错误解决:
在安装完后,直接运行python,然后输入from numpy import*,出现了
"ImportError: Error importing numpy: you should not try to import numpy > from its source directory; please exit the numpy source tree, and > relaunch your python intepreter from there." 的错误,通过搜资料,发现是因为没有进对正确的路径,在运行此命令时,需要进入的路径是numpy下的tests文件夹,也就是cd numpy/tests,然后再来进行测试是否安装成功的命令。
[yqtao@localhost ~]$ python
Python 2.7.5 (default, Sep 15 2016, 22:37:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy import * //导入函数库
>>> eye(4) //生成单位矩阵
array([[ 1., 0., 0., 0.],
[ 0., 1., 0., 0.],
[ 0., 0., 1., 0.],
[ 0., 0., 0., 1.]])
本文详细介绍了在Linux环境下安装NumPy库的步骤,包括下载源码包、解压缩、进入目录以及使用root权限运行setup.py进行安装。在安装过程中需要注意确保在root环境下执行安装命令,以避免权限问题。
2万+

被折叠的 条评论
为什么被折叠?



