python安裝numpy和pandas

  最近要對一系列數據作同比比較,須要用到numpy和pandas來計算,不過使用python安裝numpy和pandas由於linux環境沒有外網遇到了不少問題就記下來了。首要條件,python版本必須是2.7以上。html

linux首先安裝依賴包python

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.htmllinux

  一、 pip方式安裝c++

若是有外網通常推薦使用pip安裝,linux下和windows下都可使用pip安裝git

python -m pip install --upgrade pip

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

但很快就會發現這些源安裝超級慢,因此我推薦你們使用豆瓣的源github

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

  二、若是服務器上沒有外網使用不了pip,則須要使用源碼安裝。推薦你們在豆瓣pypi下載,速度更快  https://pypi.doubanio.com/simple/?allow_list_dir=1windows

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安裝。ui

安裝pandas會提示 ImportError: Building pandas requires cython則須要安裝Cython或者升級Cython先,下載連接 https://pypi.python.org/pypi/Cython/ 。windows下pip安裝以下spa

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-dateutil的提示則是該庫版本太低。先下載six最新版本1.9.0(下載地址),而後更新 python-dateutil到新版本2.5.3版本(下載地址)。

最後運行若是出現 /usr/lib64/libstdc++.so.6: ELF file OS ABI invalid的錯誤則將 /usr/lib64/libstdc++.so.6軟鏈指向低版本的 libstdc++.so.6.0.8,不要指向高版本 libstdc++.so.6.0.20。

至此就安裝成功了。

總結,花了一上午安裝這個主要是由於下載源慢,依賴包多。因此建議你們都是用pypi豆瓣源,直接在simple下面搜你須要的安裝包。

原創文章,轉載請備註原文地址 http://www.cnblogs.com/lxmhhy/p/6029465.html

相關文章
相關標籤/搜索