I recently updated my anaconda package with $conda update conda and then $conda update anaconda After that update my matplotlib is not working anymore and every time I try to run Jupyter notebook and import matplotlib, it says 'The kernel appears to have died. It will restart automatically.'

And it leaves with a ton of message starting like this:

Bad key "patch.force_edgecolor" on line 33 in
You probably need to get an updated matplotlibrc file from
or from the matplotlib source distribution

I am using Ubuntu 16.04 LTS and python 2.7 . Any suggestion on how to fix this issue?


If you don't want to mess up the matplotlib that you already have installed in Anaconda, you can install second instance of matplotlib inside a Python virtual environment (virtualenv) alongside the matplotlib that is installed in Anaconda. Installing Jupyter, matplotlib and whatever else you need with pip is easy and straightforward in virtualenv.

virtualenv allows you to create a sandboxed and isolated environment where Python packages can be installed without interfering with other packages on the same machine.

  1. Install Python virtual environment creator (virtualenv):

    sudo apt install python-virtualenv virtualenv  
  2. Make a new directory (I'll call it PythonVirtualEnv in this example) for the Python virtual environment and setup the Python virtual environment with Python and pip in it.

    cd ~  
    mkdir PythonVirtualEnv
    virtualenv PythonVirtualEnv 
  3. Install some packages.

    cd ~/PythonVirtualEnv  
    source bin/activate
    pip install jupyter matplotlib 
  4. Deactivate the Python virtual environment before leaving it.


Creating an environment with a custom Python interpreter

sudo apt install python3-virtualenv 
cd ~  
mkdir Python3VirtualEnv
virtualenv --python=/usr/bin/python3 Python3VirtualEnv # /usr/bin/python3 is the default location of the python3 executable
cd ~/Python3VirtualEnv  
source bin/activate
pip3 install jupyter matplotlib  

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.