- History
- Install other softwares
- Install packages
- Install Python
- Install other system packages
- Install Python packages
- Use Anaconda Python distribution and its package management and environment management
- Alternative to Anaconda, set up project-specific Python environment using virtualenv and system Python
- Other packages
- References
History
- 2016-3: Tested on macOS 10.11.3
Install other softwares
-
Install XQuartz.
-
Install MacTeX.
-
Install Home brew.
-
Install Xcode and command-line tools.
xcode-select --install
-
Include only the necessary paths in
$PATH
:bash$ echo $PATH /usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Library/TeX/texbin:/usr/X11/bin:/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
Install packages
brew install cmake
Install Python
-
Make sure you start from a clean and error-free state with Homebrew:
brew doctor
Check outdated packages:
brew outdated
Update:
brew update
brew upgrade
Add additional repositories and re-check:
brew tap homebrew/science
brew tap homebrew/python
brew doctor
brew update
brew upgrade
brew doctor
-
Install Python:
$ brew install python python3 $ which python /usr/local/bin/python $ python --version Python 2.7.11 $ which python3 /usr/local/bin/python $ python3 --version Python 3.5.1
-
This actually also installs the package management system
pip
:$ which pip /usr/local/bin/pip $ which pip3 /usr/local/bin/pip3
Install other system packages
brew install libtiff
brew install libjpeg
brew install webp
brew install py2cairo
brew install cairo
brew install little-cms2
brew install imagemagick --with-fftw --with-librsvg --with-x11
brew install graphviz --with-librsvg --with-x11
brew install qt pyqt
brew install zmq
brew install zeromq
brew install gcc
brew install freetype
Install Python packages
Warnings: * For the same software or library, install once using
brew install <package>
or pip install
<package>
but not both. The latter is usually more
up-to-date. * Do not use sudo pip
.
Install with brew
brew install homebrew/python/matplotlib --with-cairo --with-tex
Alternatively, install with pip
-
Update:
pip install --upgrade pip pip install pip-review pip3 install --upgrade pip pip3 install pip-review
-
Virtual environment:
pip install virtualenv pip install virtualenvwrapper
-
IPython
pip install "ipython[all]" pip3 install "ipython[all]"
Start IPython notebook server by:
ipython notebook
ipython3 notebook
and open http://localhost:8889/tree in Web browser.
-
Unit testing:
pip install nose
-
Scientific computing:
pip install numpy pip install scipy pip install sympy python -c 'import numpy ; numpy.test();' python -c 'import scipy ; scipy.test();'
-
Data management:
pip install pandas
-
pip install nltk
-
Graphics related:
pip install snakeviz pip install pyzmq pip install pygments
For matplotlib
choose only one of the
following:
brew install homebrew/python/matplotlib --with-cairo --with-tex
pip install matplotlib
-
Others:
pip install q
Use Anaconda Python distribution and its package management and environment management
- Should I use Anaconda?
Anaconda is itself a Python distribution including Python and
lots of Python packages for scientific and technical computing. It
also includes a package management system as well as a environment
management system. It's fairly popular and convenient to install
and use for beginners. But by using pip
as the package
management system the virtualenv
and
virtualenvwrapper
packages as the environment
management system, one can live without Anaconda. Roughly speaking,
Anaconda is to Python what stack
is to Haskell.
-
Install Anaconda (see instruction). Put Anaconda
bin
andman
paths in$PATH
in~/.bashrc
:export PATH=$HOME/anaconda/bin:$PATH export MANPATH=$HOME/anaconda/share/man:$MANPATH
Update
conda update conda
conda update anaconda
-
Create a new environment
my-env
:conda create -n my-env python=2.7 anaconda
-
Activate the environment:
source activate my-env
-
Install and/or update packages:
conda update conda conda update anaconda conda update pip conda update ipython ipython-notebook
Alternative to Anaconda, set up project-specific Python
environment using virtualenv
and system Python
Let's install specific packages and/or specific versions of some
packages in isolated environment named my-env
for a
specific project.
-
Create a virtual environment named
my-env
:cd path/to/project virtualenv my-env git ignore my-env
-
Activate the virtual environment:
$ source my-env/bin/activate $ echo $VIRTUAL_ENV /Users/meng/project/my-env (my-env)
Other packages
GraphLab, a machine-learning package
You can obtain a free 1-year license for educational purposes such as taking the University of Washington Machine Learning course series on coursera.org.