我安装了 opencv 以及所有依赖项。安装后我尝试导入 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.
如何安装 matplotlib?
最佳答案
看起来您的用户没有在您的系统中安装软件包的权限(对于所有用户)。以下是针对 Linux、macOS 和 Windows 解决此问题的方法。
Linux/macOS
从您的终端,您可以仅为您的用户安装包,如下所示:
pip install <package> --user
或
您可以使用 su
或 sudo
从您的终端,将软件包安装为 root
:
sudo pip install <package>
window
在命令提示符下,您可以仅为您的用户安装包,如下所示:
pip install <package> --user
或
您可以按照以下步骤以管理员身份安装包:
- 右键单击命令提示符图标
- 选择选项
Run This Program As An Administrator
- 运行命令
pip install <package>
关于python - 安装matplotlib出现Permission denied错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50087098/