Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied error by installing matplotlib

I installed opencv with all dependencies. After the installation I tried to import matplotlib for a simple example.

Then I got the following error, when I tried to install matplotlib via pip with pip install matplotlib:

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/kiwisolver.cpython-35m-x86_64-linux-gnu.so'
Consider using the `--user` option or check the permissions.

What can I do to install matplotlib?

like image 475
Maximilian von Unwerth Avatar asked Apr 29 '18 13:04

Maximilian von Unwerth


People also ask

Could not install packages due to an EnvironmentError errno 13 Permission denied pip install?

There might be instances when you keep getting an error “Could not install packages due to an EnvironmentError: [Errno 13] Permission denied” when you pip install. This error comes up because of missing privilege to the directory in which pip is trying to write files.

Does Python install PIP?

PIP is automatically installed with Python 2.7.9+ and Python 3.4+ and it comes with the virtualenv and pyvenv virtual environments.

How do I install pip on Windows 10?

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process.


3 Answers

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>
like image 129
Ronan Boiteau Avatar answered Oct 04 '22 15:10

Ronan Boiteau


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'.

like image 25
Deepu Mayanattanmy Avatar answered Oct 04 '22 15:10

Deepu Mayanattanmy


Try this:

sudo pip install matplotlib
like image 38
Ishara Madhawa Avatar answered Oct 04 '22 13:10

Ishara Madhawa