How to install latest versions of NumPy / Scipy / Matplotlib / IPython / Pandas on Ubuntu

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

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

+6
source share
3 answers

Using Ubuntu, here's how to install the entire NumPy / Scipy / Matplotlib / IPython / Pandas stack from Github to virtualenv using Python2.7:

Note. In the instructions below, install the latest development version of each package. If you want to install the latest tagged version, then after git clone check the tags available with

 git tag 

and select the version you want to install using

 git checkout tag-name 

Install virtualenv and virtualenvwrapper :

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

Install 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 

Update:

An advantage of the git approach is that it provides a way to always keep these packages updated:

 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.

Shortcut for using pip with GitHub directly

The above steps for cloning and installing packages can be automated to the extent with pip. For example, we can also install NumPy as follows:

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

Updating will now be easy

 pip install numpy --upgrade --force-reinstall 
Flag

--force-reinstall may be needed because pip checks the version from PyPI and does not update if the current version is at least.

+9
source

Through the distribution of Anaconda:

Download and install

 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 

Install only the packages in the header in their own environment:

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

Note. I believe that anaconda supports Python 2.6, 2.7, 3.3, and 3.4.

+8
source

In use ubuntu sudo apt-get install ipython

sudo apt-get install sympy

etc.

-6
source

Source: https://habr.com/ru/post/981445/


All Articles