使用 Ubuntu,这里是如何安装整个 NumPy/Scipy/Matplotlib/IPython/Pandas
使用 Python2.7 在 virtualenv 中从 Github 堆栈:
注意:下面的说明安装每个包的最新开发版本。如果你想安装最新的标记版本,那么在git clone 之后,检查可用的标记
git tag
并选择您要安装的版本
git checkout tag-name
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
pip install -U Cython
sudo apt-get install git
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
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
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
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
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 检查版本,如果当前版本不小,则不会更新。