Permission denied error by installing matplotlib

It looks like your user does not have the permission to install packages in your system (for all users). Here's how to fix this problem for Linux, macOS and Windows.


Linux / macOS

From your terminal, you can install the package for your user only, like this:

pip install <package> --user

OR

You can use su or sudo from your terminal, to install the package as root:

sudo pip install <package>

Windows

From the Command Prompt, you can install the package for your user only, like this:

pip install <package> --user

OR

You can install the package as Administrator, by following these steps:

  1. Right click on the Command Prompt icon
  2. Select the option Run This Program As An Administrator
  3. Run the command pip install <package>

I solved this issue by typing the following command,

pip install --user <package_name>

Example,

pip install --user tensorflow

NOTE: You should not enter your own username for this command. Please enter with '--user'.


Try this:

sudo pip install matplotlib