How to install python for data analysis - for Mac

Adam Claridge-Chang June 2015

How to install Anaconda for Mac

Google "anaconda python" and click through to the relevant download page.

Use installer to install. When complete, there will be a shortcut on your desktop that looks like below

In [1]:
from IPython.display import Image

Click on that icon, the Launcher will appear. Click on the IPython Notebook.

Install a package that is not in the Anaconda distribution

On the package's homepage, see if they offer pip installation - most will.

Most packages are hosted on the PYthon Package Index (PYPI), so are installable with pip.

For example to install RPy2, a package for running R code in IPython, you can type this in Terminal

$ pip install rpy2

How to add a folder to your path

You may want to organize your custom scripts into a folder that is not mixed in with the Anaconda modules

1) Find your bash profile

In Terminal on the command line type (without the $ sign, which is the prompt)

$ cd $ ls -a

This means "change directory to my home folder, list all files including hidden files".

You should see a file called .bash_profile listed there

2) Edit your bash profile.

Into the command line type

$ open .bash_profile

This should open in TextEdit. Add two lines to the text file:

\# Added by My Name on My Date export PYTHONPATH="/Users/myusername/path/to/folder:$PYTHONPATH"

3) Check that this worked.

Open a python session:

\>>> import sys \>>> sys.path

The new folder should now be listed in your path

In [2]:
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
     for i in installed_packages])
['abstract-rendering==0.5.1', 'alabaster==0.7.3', 'argcomplete==0.8.4', 'astropy==1.0.2', 'atom==0.3.9', 'babel==1.3', 'backports.ssl-match-hostname==', 'bcolz==0.8.1', 'beautifulsoup4==4.3.2', 'binstar==0.10.3', 'bitarray==0.8.1', 'blaze==0.8.0', 'blz==0.6.2', 'bokeh==0.8.2', 'boto==2.38.0', 'casuarius==1.1', 'cdecimal==2.3', 'cffi==0.9.2', 'chaco==4.5.0', 'clyent==0.3.4', 'colorama==0.3.3', 'conda-build==1.12.1', 'conda-env==2.1.4', 'conda==3.12.0', 'configobj==5.0.6', 'cryptography==0.8.2', 'cython==0.22', 'cytoolz==0.7.2', 'datashape==0.4.5', 'decorator==3.4.0', 'docutils==0.12', 'enable==4.4.1', 'enaml==0.9.8', 'enum34==1.0.4', 'fastcache==1.0.2', 'flask==0.10.1', 'funcsigs==0.4', 'future==0.14.3', 'futures==3.0.2', 'gevent-websocket==0.9.3', 'gevent==1.0.1', 'greenlet==0.4.6', 'grin==1.2.1', 'h5py==2.5.0', 'ipython==3.1.0', 'itsdangerous==0.24', 'jdcal==1.0', 'jedi==0.8.1', 'jinja2==2.7.3', 'jsonschema==2.4.0', 'kiwisolver==0.1.3', 'llvmlite==0.4.0', 'llvmpy==0.12.7', 'lxml==3.4.4', 'markupsafe==0.23', 'matlabengineforpython==R2014b', 'matplotlib==1.4.3', 'mistune==0.5.1', 'mock==1.0.1', 'multipledispatch==0.4.7', 'networkx==1.9.1', 'nltk==3.0.2', 'nose==1.3.6', 'nptdms==0.6.2', 'numba==0.18.2', 'numexpr==2.3.1', 'numpy==1.9.2', 'oct2py==2.4.0', 'odo==0.3.2', 'openpyxl==2.0.2', 'pandas==0.16.1', 'patsy==0.3.0', 'pep8==1.6.2', 'pil==1.1.7', 'pillow==2.7.0', 'pip==7.0.3', 'ply==3.4', 'psutil==2.2.1', 'ptyprocess==0.4', 'py==1.4.26', 'pyasn1==0.1.7', 'pyaudio==0.2.7', 'pybeeswarm==1.0.0', 'pycosat==0.6.1', 'pycparser==2.12', 'pycrypto==2.6.1', 'pycurl==', 'pyface==4.4.0', 'pyflakes==0.8.1', 'pygments==2.0.2', 'pymongo==2.8', 'pyopenssl==0.15.1', 'pyparsing==2.0.3', 'pytest==2.7.0', 'python-dateutil==2.4.1', 'pytz==2015.4', 'pyyaml==3.11', 'pyzmq==14.6.0', 'redis==2.10.3', 'requests==2.7.0', 'rope==0.9.4', 'rpy2==2.5.6', 'runipy==0.1.3', 'scikit-image==0.11.3', 'scikit-learn==0.16.1', 'scikits.bootstrap==0.3.2', 'scipy==0.15.1', 'seaborn==0.5.1', 'setuptools==15.2', 'singledispatch==', 'six==1.9.0', 'snowballstemmer==1.2.0', 'sockjs-tornado==1.0.1', 'sphinx-rtd-theme==0.1.7', 'sphinx==1.2.3', 'spyder==2.3.4', 'sqlalchemy==1.0.4', 'statsmodels==0.6.1', 'svgutils==0.1.0', 'sympy==0.7.6', 'tables==3.1.1', 'terminado==0.5', 'toolz==0.7.2', 'tornado==4.1', 'traits==4.4.0', 'traitsui==4.4.0', 'ujson==1.33', 'unicodecsv==0.9.4', 'werkzeug==0.10.4', 'xlrd==0.9.3', 'xlsxwriter==0.7.2', 'xlwt==1.0.0']

How to share a notebook on nbviewer

1) Get a Github account

2) Make your notebook

3) Watch this video

4) Share the link to the notebook

In [ ]: