【问题标题】:How can I install the latest versions of NumPy/Scipy/Matplotlib/IPython/Pandas on Ubuntu如何在 Ubuntu 上安装最新版本的 NumPy/Scipy/Matplotlib/IPython/Pandas
【发布时间】:2015-03-22 13:49:15
【问题描述】:

用户sometimes need to know 如何安装比他们的操作系统包管理器提供的更新版本的 Pandas。 Pandas 需要 NumPy,最适合与 SciPy、Matplotlib 和 IPython 搭配使用。

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

【问题讨论】:

  • @unutbu,我认为latest versiondevelopment version 之间存在差异。在您的第一个 cw 答案中,您描述了如何从 git 安装最新的快照。大多数用户可能更喜欢最新的稳定版本。我认为在您的问题中澄清这一点可能是个好主意。
  • @cel:感谢您的评论。我在社区 wiki 中添加了有关如何选择最新版本的说明。
  • 现在我开始怀疑是否有针对此的 PPA。

标签: numpy matplotlib pandas scipy ipython


【解决方案1】:

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

注意:下面的说明安装每个包的最新开发版本。如果你想安装最新的标记版本,那么在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

制作一个虚拟环境

mkvirtualenv --system-site-packages dev
workon dev

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

将站点包添加到 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

按照上述说明确保构建干净,然后重新构建并 重新安装包。

直接在 GitHub 上使用 pip 的简写

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

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

更新将只是

pip install numpy --upgrade --force-reinstall

可能需要--force-reinstall 标志,因为 pip 从 PyPI 检查版本,如果当前版本不小,则不会更新。

【讨论】:

  • 我认为答案中应该提到anaconda和canopy。这是安装 scipy 堆栈的一种非常方便的方式,尤其是对于 mac 和 windows 用户。
  • @cel:这是一个社区维基。请随时添加信息。
  • @gboffi:我忘记包含有关配置 virtualenv 包装器的说明。我已经编辑了上面的帖子以显示如何。
【解决方案2】:

在 ubuntu 中使用 sudo apt-get install ipython

sudo apt-get install sympy

【讨论】:

  • 没错,但包管理器中的 python 包通常不是最新的可用版本。这就是这个线程开始的原因。
  • 如果你发布代码,你应该确保它是正确的。我会是sudo apt-get install python-sympy...
【解决方案3】:

通过 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。

【讨论】:

    猜你喜欢
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-05
    • 2016-03-04
    • 1970-01-01
    相关资源
    最近更新 更多