码迷,mamicode.com
首页 > 编程语言 > 详细

python安装numpy和pandas

时间:2016-11-04 13:55:22      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:.com   问题   round   x86   pypi   sea   freetype   atp   dateutil   

  最近要对一系列数据做同比比较,需要用到numpy和pandas来计算,不过使用python安装numpy和pandas因为linux环境没有外网遇到了很多问题就记下来了。首要条件,python版本必须是2.7以上。

linux首先安装依赖包

yum -y install blas blas-devel lapack-devel lapack
yum -y install seaborn scipy
yum -y install freetype freetype-devel libpng libpng-devel
yum -y install python-pip
yum -y install pytz
yum -y install python-dateutil

 

windows安装pip即可,具体方法参考pip官网 http://pip-cn.readthedocs.io/en/latest/installing.html

  1、 pip方式安装

如果有外网一般推荐使用pip安装,linux下和windows下均可使用pip安装

python -m pip install --upgrade pip

pip install --user numpy scipy matplotlib jupyter pandas sympy nose

但很快就会发现这些源安装超级慢,所以我推荐大家使用豆瓣的源

pip install matplotlib -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip install numpy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip install pandas -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip install seaborn scipy  -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

  2、如果服务器上没有外网使用不了pip,则需要使用源码安装。推荐大家在豆瓣pypi下载,速度更快  https://pypi.doubanio.com/simple/?allow_list_dir=1

python numpy安装包下载地址是 https://pypi.python.org/pypi/numpy/,pandas的安装包下载地址是 https://pypi.python.org/pypi/pandas,github地址是 https://github.com/pandas-dev

 

tar -xzf numpy-1.11.2.tar.gz
cd numpy-1.11.2
python setup.py build  # 编译几分钟
python setup.py install  

安装pandas会提示 ImportError: Building pandas requires cython则需要安装Cython或者升级Cython先,下载链接 https://pypi.python.org/pypi/Cython/ 。windows下pip安装如下

pip install Cython

linux下可使用yum安装或者pip安装

yum install -y Cython.x86_64

如果需要更新到最新版本的Cython则下载源码后安装

cd Cython-0.25.1
python setup.py build
python setup.py install

然后是按照pandas

cd pandas-0.19.0
python setup.py build   # 比较久
python setup.py install

至此就安装成功了。

总结,花了一上午安装这个主要是因为下载源慢,依赖包多。所以建议大家都是用pypi豆瓣源,直接在simple下面搜你需要的安装包。

原创文章,转载请备注原文地址 http://www.cnblogs.com/lxmhhy/p/6029465.html

知识交流讨论请加qq:1130010617。谢谢合作。

python安装numpy和pandas

标签:.com   问题   round   x86   pypi   sea   freetype   atp   dateutil   

原文地址:http://www.cnblogs.com/lxmhhy/p/6029465.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!