Skip to content

Instantly share code, notes, and snippets.

@Fohlen
Created November 29, 2018 18:09
Show Gist options
  • Save Fohlen/a7e040bb0e5314912cb7b7b89d43b33f to your computer and use it in GitHub Desktop.
Save Fohlen/a7e040bb0e5314912cb7b7b89d43b33f to your computer and use it in GitHub Desktop.
How to set up matplotlib on OSX with Python2.7
# Setting up Matplotlib with python2.7 can be superb pain to set up but a lot of tutorials still use this especially for scikit
# We assume here that you have installed python2.7 via brew (brew install python2.7)
# This means python2.7 is your brew python while python will be your system python
# Configure backend
echo "backend: WXAgg" >> ~/.matplotlib/matplotlibrc
# Go inside your virtualenv with your project and everything
pip install -U wxPython
# After that you will need to exit your VENV
# Since OSX can sometimes be a bit retarded: you need a "framework" python version (what Apple bundles for instance)
# Our workaround is: point PYTHONHOME to virtual env, then use the system python to execute
export PYTHONHOME=/absolute/path/to/your/venv
python script_that_renders_pyplot.py # this will use system python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment