Home » Essential Libraries for Data Science on a Mac

Essential Libraries for Data Science on a Mac

by Jack Simpson

I recently ran a fresh install on my Mac and thought I’d take the opportunity to document the libraries and programs I find incredibly useful.

The Python libraries I’ll frequently pip3 install include:

  • numpy [fundamental package for all numerical computing in Python]
  • pandas [dataframes and other useful things]
  • scipy [statistics]
  • nltk [natural language processing]
  • spacy [natural language processing; followed by `python3 -m spacy.en.download all`]
  • matplotlib [plotting]
  • scikit-learn [machine learning]
  • seaborn [visualisation]
  • virtualenv [virtual environments for Python]
  • jupyter [notebooks]
  • jupyterlab [enhanced environment for notebooks]
  • R Kernel for Jupyter [write R in notebooks]
  • flask [web development]
  • requests [fetching online content]
  • beautifulsoup4 [parsing html/xml]
  • pillow [fork of Python imaging library – lightweight image processing]
  • pymysql [using Python to query MySQL databases]
  • mypy-lang [check type annotations in Python]
  • ipython-sql [SQL kernel for Jupyter notebook]
  • version_information [nice package for outputting system information]

I also use homebrew to manage other software on my machine, and will brew install:

  • python3
  • pkg-config
  • mysql
  • R
  • opencv3 –c++11 –with-contrib –with-ffmpeg –with-gphoto2 –with-gstreamer –with-jasper –with-opengl –with-python3 –with-qt5 –with-tbb

Note that to get OpenCV 3 to work with Python 3 installed via Homebrew you’ll also need to run this command after the install:

echo /usr/local/opt/opencv3/lib/python3.6/site-packages >> /usr/local/lib/python3.6/site-packages/opencv3.pth

Keep in mind the following message which will be relevant if you want to compile C++ programs utilising OpenCV 3:

This formula is keg-only, which means it was not symlinked into /usr/local. opencv3 and opencv install many of the same files. Generally there are no consequences of this for you. If you build your own software and it requires this formula, you’ll need to add to your build variables:

LDFLAGS:  -L/usr/local/opt/opencv3/lib

CPPFLAGS: -I/usr/local/opt/opencv3/include

PKG_CONFIG_PATH: /usr/local/opt/opencv3/lib/pkgconfig

Finally, if you install MySQL, you’ll be notified that it has been installed with a root user with no password. You can update this is with the mysql_secure_installation command. If you want to have MySQL on all the time, you can run brew services start mysql, otherwise you can turn it off or on with  mysql.server start/stop.

This is mainly for my own future reference, but I hope that it can be of use to others as well.

You may also like