简体   繁体   English

Python 操作系统:[Errno 13] 权限被拒绝

[英]Python os: [Errno 13] Permission Denied

I am trying to get a deep learning network ( https://github.com/MIC-DKFZ/nnUNet ) to work with my own dataset and I am having trouble with the paths.我正在尝试使用深度学习网络 ( https://github.com/MIC-DKFZ/nnUNet ) 来处理我自己的数据集,但我在路径方面遇到了问题。 I have used several approaches to define my paths.我使用了几种方法来定义我的路径。 The authors import the following packages for this issue:作者为此问题导入了以下包:

import os

from batchgenerators.utilities.file_and_folder_operations import maybe_mkdir_p, join

With this, I have tried the following lines, separately:有了这个,我分别尝试了以下几行:

base = os.environ["nnUNet_base"]

base = join("Tortuosity", "nnUNet_base")

base = "Tortuosity/nnUNet_base"

I have the nnUNet_base directory inside the Tortuosity directory.我有nnUNet_base的目录里面Tortuosity的目录。 With the first approach it seems that it is not registering the directory correctly (I ask for print("base =", base) and in return I get None . For the second and third approaches, I obtain the following error:对于第一种方法,它似乎没有正确注册目录(我要求print("base =", base)并且作为回报我得到None 。对于第二种和第三种方法,我得到以下错误:

Traceback (most recent call last):
  File "experiment_planning/plan_and_preprocess_task.py", line 18, in <module>
    from nnunet.paths import base,splitted_4d_output_dir, cropped_output_dir, preprocessing_output_dir, raw_dataset_dir, network_training_output_dir
  File "/home/pere/anaconda3/envs/nnunet_env/nnUNet/nnunet/paths.py", line 51, in <module>
    maybe_mkdir_p(splitted_4d_output_dir)
  File "/home/pere/anaconda3/envs/nnunet_env/lib/python3.6/site-packages/batchgenerators/utilities/file_and_folder_operations.py", line 40, in maybe_mkdir_p
    os.mkdir(os.path.join("/", *splits[:i+1]))
PermissionError: [Errno 13] Permission denied: '/nnUNet_base'

I do not know how to habilitate permissions in this case.在这种情况下,我不知道如何恢复权限。 Please help, what should I do to effectively define the paths for my case?请帮助,我应该怎么做才能有效地定义我的案例的路径? I am running a VM with Ubuntu 16.04 in a Mac.我在 Mac 上运行带有 Ubuntu 16.04 的 VM。

Thank you!谢谢!

The error says this:错误是这样说的:

os.mkdir(os.path.join("/", *splits[:i+1]))

That means, tht the path is under / and not in your home Directory.这意味着,路径在 / 下而不是在您的主目录中。 The fix that just use the absolute path at it is written in the comments of nunet.只使用绝对路径的修复写在 nunet 的注释中。

base = "/home/pere/Tortuosity/nnUNet_base"

If Tortuosity is directly in your home folder.如果 Tortuosity 直接在您的主文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM