最近在服务器上用conda命令安装python依赖包时总是报错,如下:
Collecting package metadata (current_repodata.json): failed
NotWritableError: The current user does not have write permissions to a required path.
path: /opt/anaconda3/pkgs/cache/8f77de01.json
uid: 984
gid: 984
If you feel that permissions on this path are set incorrectly, you can manually
change them by executing
$ sudo chown 984:984 /opt/anaconda3/pkgs/cache/8f77de01.json
In general, it's not advisable to use 'sudo conda'.
原因:
创建Anaconda时使用了root权限,所以在普通用户使用时就会报错,提示对Anaconda没权限修改。
解决办法:
给本用户Anaconda文件夹的权限:cd到anaconda3文件夹所在的路径(我的是/opt),运行
$ sudo chown -R username anaconda3 #username替换为自己用户名
之后就可以正常安装python包啦!
参考链接: