python中怎么安装numpy和pandas

python中怎么安装numpy和pandas

今天就跟大家聊聊有关python中怎么安装numpy和pandas,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

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

如提示缺少 setuptools 则从https://pypi.python.org/pypi/setuptools下载 setuptools安装。

安装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

看完上述内容,你们对python中怎么安装numpy和pandas有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。