如何在Ubuntu上安装最新版本的NumPy / Scipy / Matplotlib / IPython / Pandas

时间:2015-01-23 13:46:53

标签: numpy matplotlib pandas scipy ipython

用户sometimes need to know如何安装比他们的OS程序包管理器提供的更新版本的Pandas。 Pandas需要NumPy,并且最适合SciPy,Matplotlib和IPython。

如何安装最新版本的NumPy / Scipy / Matplotlib / IPython / Pandas?

3 个答案:

答案 0 :(得分:9)

使用Ubuntu,这里是如何安装整个NumPy / Scipy / Matplotlib / IPython / Pandas 使用Python2.7从Github在virtualenv中堆栈:

注意:以下说明将安装每个软件包的最新开发版本。如果您希望安装最新的标记版本,请在git clone之后检查可用的标记

git tag

并选择您要安装的版本

git checkout tag-name

安装virtualenvvirtualenvwrapper

sudo apt-get install python-virtualenv
sudo pip install virtualenvwrapper

# edit ~/.bashrc to include
source /usr/share/virtualenvwrapper/virtualenvwrapper.sh

# edit ~/.profile to include
export WORKON_HOME=$HOME/.virtualenvs

# You may have to log out then log back in to make the change effective

制作一个virtualenv

mkvirtualenv --system-site-packages dev
workon dev

# If you want to make this virtual environment your default Python,
# edit ~/.bashrc to include
workon dev

将site-packages添加到sys.path:

add2virtualenv $USER/.virtualenvs/dev/lib/python2.7/site-packages

安装Cython

pip install -U Cython

安装git

sudo apt-get install git

安装NumPy

cd ~/src
git clone https://github.com/numpy/numpy.git

sudo apt-get install python-dev build-essential  
sudo apt-get install libatlas-base-dev libatlas3gf-base

# ensure clean build
# this is not necessary the first time, but useful when upgrading
cd ~/src/numpy
/bin/rm -rf ~/src/numpy/build
cdsitepackages && /bin/rm -rf numpy numpy-*-py2.7.egg-info

cd ~/src/numpy
python setup.py build --fcompiler=gnu95
python setup.py install

安装SciPy

cd ~/src
git clone https://github.com/scipy/scipy.git

# ensure clean build
cd ~/src/scipy
/bin/rm -rf ~/src/scipy/build
cdsitepackages && /bin/rm -rf scipy scipy-*-py2.7.egg-info

cd ~/src/scipy
git clean -xdf
python setup.py install

安装Matplotlib依赖项

pip install -U pyparsing
pip install -U six
pip install -U python-dateutil
pip install -U pytz
sudo apt-get install libzmq-dev
pip install -U tornado pygments pyzmq 
pip install -U nose
sudo apt-get install python-qt4 python-qt4-doc python-pyside python-cairo python-wxgtk2.8 python-gtk2 dvipng

apt-cache depends python-matplotlib | awk '/Depends:/{print $2}' | xargs dpkg --get-selections
sudo apt-get build-dep python-matplotlib

安装Matplotlib

cd ~/src/
git clone https://github.com/matplotlib/matplotlib

# ensure clean build
cd ~/src/matplotlib
/bin/rm -rf ~/src/matplotlib/build
cdsitepackages && /bin/rm -rf matplotlib* mpl_toolkits

# compile and install
cd ~/src/matplotlib
python setup.py build
python setup.py install

安装IPython

cd ~/src
git clone https://github.com/ipython/ipython.git

# ensure clean build
cd ~/src/ipython
/bin/rm -rf ~/src/ipython/build
cdsitepackages && /bin/rm -rf ipython-*-py2.7.egg

cd ~/src/ipython
python setupegg.py install

安装Pandas

cd ~/src
git clone https://github.com/pydata/pandas.git
cd ~/src/pandas

# update
git fetch origin
git rebase --interactive origin/master

# ensure clean build and install
/bin/rm -rf ~/src/pandas/{build,dist} && cdsitepackages && /bin/rm -rf pandas* && cd ~/src/pandas && python setup.py build_ext --inplace && python setup.py install 

更新

的优势 git方法是它提供了一种始终保留这些包的方法 先进的日期:

cd ~/src/package-name
git fetch origin
git rebase --interactive origin/master

按照上面的说明确保完整的构建,然后重建和 重新安装包。

直接使用pip与GitHub的简写

克隆和安装软件包的上述步骤可以通过pip实现自动化。例如,我们也可以像这样安装NumPy:

pip install git+git://github.com/numpy/numpy.git

更新将只是

pip install numpy --upgrade --force-reinstall
可能需要

--force-reinstall标志,因为pip会检查PyPI中的版本,如果当前版本不小,则不会更新。

答案 1 :(得分:8)

通过Anaconda发行版:

下载并安装

wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
chmod +x miniconda.sh
./miniconda.sh -b
export PATH=/home/travis/miniconda/bin:$PATH
conda update conda --yes

在他们自己的环境中只安装标题中的包:

conda create --name myenv --yes python=3.4 pandas matplotlib ipython-notebook
source activate myenv

注意:我相信anaconda支持Python版本2.6,2.7,3.3和3.4。

答案 2 :(得分:-6)

在ubuntu中使用 sudo apt-get install ipython

sudo apt-get install sympy