ipython怎么安装numpy,如何在Ubuntu上安装最新版本的NumPy / Scipy / Matplotlib / IPython / Pandas...

Users sometimes need to know how to install a newer version of Pandas than their OS package manager offers. Pandas requires NumPy, and works best with SciPy, Matplotlib and IPython.

How can I install the latest versions of NumPy/Scipy/Matplotlib/IPython/Pandas?

解决方案

Using Ubuntu, here is how to install the entire NumPy/Scipy/Matplotlib/IPython/Pandas

stack from Github in a virtualenv using Python2.7:

Note: The instructions below install the latest development version of each package. If you wish to install the latest tagged version, then after git clone, inspect the tags available with

git tag

and select the version you wish to install with

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

Make a 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

Add site-packages to sys.path:

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

Install Cython

pip install -U Cython

Install git

sudo apt-get install git

Install 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

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

Install Matplotlib dependencies

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

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

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

Updating:

The advantage of

the git approach is that it provides a way to always keep these packages

up-to-date:

cd ~/src/package-name

git fetch origin

git rebase --interactive origin/master

Follow the instructions above to ensure a clean build, and then rebuild and

reinstall the package.

Shorthand for using pip with GitHub directly

The above steps to clone and install packages can be automated to an extent with pip. For example, we can also install NumPy like this:

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

The updating would then be just

pip install numpy --upgrade --force-reinstall

--force-reinstall flag may be needed because pip checks the version from PyPI and doesn't update if the current version isn't smaller.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值