[英]Permission denied error by installing matplotlib
I installed opencv with all dependencies.我安装了带有所有依赖项的opencv 。 After the installation I tried to import matplotlib for a simple example.
安装后,我尝试导入matplotlib作为一个简单示例。
Then I got the following error, when I tried to install matplotlib via pip with pip install matplotlib
:然后,当我尝试使用
pip install matplotlib
通过 pip 安装 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?我可以做什么来安装 matplotlib?
Looks like your user doesn't 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 和 Windows 解决此问题的方法。
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
:您可以从终端使用
su
或sudo
以root
身份安装软件包:
sudo pip install <package>
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:您可以按照以下步骤以管理员身份安装软件包:
Run This Program As An Administrator
Run This Program As An Administrator
身份Run This Program As An Administrator
pip install <package>
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'.
请输入'--user'。
尝试这个:
sudo pip install matplotlib
You don't have the permission to install a package globally, so you can use sudo pip install matplotlib
, but it isn't recommended.您没有全局安装包的权限,因此您可以使用
sudo pip install matplotlib
,但不建议这样做。
The recommended way is using venv or virtualenv to create a virtual environment.推荐的方式是使用venv或virtualenv创建虚拟环境。
venv:静脉:
python3 -m venv <DIR>
python3 -m venv <DIR>
source <DIR>/bin/activate
source <DIR>/bin/activate
pip install matplotlib
pip install matplotlib
Try this: 尝试这个:
sudo pip install <xyz>
And/Or this: 和/或这个:
sudo pip3 install <xyz>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.