python - Conda 软件包安装 [Errno 13] 安装 conda-forge::protobuf-3.8.0 时权限被拒绝

标签 python permissions installation pytorch conda

我有一个使用 Python 3.6 的 conda 环境,但我的 Pytorch 安装出现问题,所以我尝试再次安装它。在安装快结束时,我收到此错误:

ERROR conda.core.link:_execute(700): An error occurred while installing package 'conda-forge::protobuf-3.8.0-py36h6de7cb9_1'.
Rolling back transaction: done

[Errno 13] Permission denied: '/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/google/protobuf/__init__.py'
()

此外,它说“环境不一致”,这可能表明某些事情已经出错了。

完整细节:
$ conda install pytorch torchvision -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: - 
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:

  - conda-forge/osx-64::tensorboard==1.14.0=py36_0
  - conda-forge/noarch::tensorboardx==1.9=py_0
done

## Package Plan ##

  environment location: /Users/myusername/anaconda3/envs/torch

  added / updated specs:
    - pytorch
    - torchvision


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    intel-openmp-2019.4        |              233         887 KB
    mkl-2019.4                 |              233       101.9 MB
    pytorch-1.3.1              |          py3.6_0        32.7 MB  pytorch
    torchvision-0.4.2          |         py36_cpu         5.9 MB  pytorch
    ------------------------------------------------------------
                                           Total:       141.4 MB

The following NEW packages will be INSTALLED:

  intel-openmp       pkgs/main/osx-64::intel-openmp-2019.4-233
  libprotobuf        conda-forge/osx-64::libprotobuf-3.8.0-hfbae3c0_0
  mkl                pkgs/main/osx-64::mkl-2019.4-233
  protobuf           conda-forge/osx-64::protobuf-3.8.0-py36h6de7cb9_1
  pytorch            pytorch/osx-64::pytorch-1.3.1-py3.6_0
  torchvision        pytorch/osx-64::torchvision-0.4.2-py36_cpu

The following packages will be UPDATED:

  openssl                                 1.1.1c-h01d97ff_0 --> 1.1.1d-h0b31af3_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
pytorch-1.3.1        | 32.7 MB   | ##################################### | 100% 
torchvision-0.4.2    | 5.9 MB    | ##################################### | 100% 
mkl-2019.4           | 101.9 MB  | ##################################### | 100% 
intel-openmp-2019.4  | 887 KB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
ERROR conda.core.link:_execute(700): An error occurred while installing package 'conda-forge::protobuf-3.8.0-py36h6de7cb9_1'.
Rolling back transaction: done

[Errno 13] Permission denied: '/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/google/protobuf/__init__.py'
()

更新:
我尝试卸载 tensorboard 和 tensorboardx 但发生了同样的错误,阻止了卸载。

还:

试过 pip uninstall protobuf但这导致了类似的错误:
Uninstalling protobuf-3.10.0:
  Would remove:
...


ERROR: Exception:
Traceback (most recent call last):
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/shutil.py", line 544, in move
    os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/google/protobuf/' -> '/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/google/~-otobuf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/pip/_internal/commands/uninstall.py", line 79, in run
    auto_confirm=options.yes, verbose=self.verbosity > 0,
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 755, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/pip/_internal/req/req_uninstall.py", line 394, in remove
    moved.stash(path)
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/pip/_internal/req/req_uninstall.py", line 283, in stash
    renames(path, new_path)
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 338, in renames
    shutil.move(old, new)
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/shutil.py", line 556, in move
    rmtree(src)
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/shutil.py", line 389, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "/Users/myusername/anaconda3/envs/torch/lib/python3.6/shutil.py", line 387, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [Errno 13] Permission denied: '/Users/myusername/anaconda3/envs/torch/lib/python3.6/site-packages/google/protobuf/descriptor.py'

除了删除整个环境并重新开始之外,我不知道如何解决这个问题。

最佳答案

当我尝试从我的环境中更新/卸载 python 包(matplotlib)时,我遇到了类似的错误。原因原来是我有另一个正在运行的 python 应用程序并打开了一个 matplotlib 绘图窗口,因此由于一个进程正在访问该包,因此无法删除它。
当我关闭所有 python 程序时,我能够在没有权限错误的情况下升级包。
故事如此寓意,如果您尝试更新/卸载软件包,请确保所有 python 脚本都没有运行 .

关于python - Conda 软件包安装 [Errno 13] 安装 conda-forge::protobuf-3.8.0 时权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59063954/

相关文章:

ios - fork() 失败 (1 : Operation not permitted)

c# - 以编程方式为 C# 中的文件添加安全权限

ruby - 使用 activerecord-mysql-adapter 安装 Redmine

Android & Servers - 可以用什么服务器软件,一头雾水

python - bitfinex api v2 错误,无效 key

python - 我的输出需要是这样的,它没有出现我需要的样子

linux ELF节和头访问权限

python - 安装pygame时出错

python - 使用子进程在管道输出上调用 sed 结果不一致

python - 如何使用递归多次划分数字并跟踪迭代?