PermissionError: [Errno 13] 检索本地文件中的 tif 图像时权限被拒绝

问题描述 投票:0回答:1

我正在尝试使用 python 获取一个模块来在我的计算机上导入 tif 文档表单文件

这是我收到的错误消息:

权限错误:[Errno 13] 权限被拒绝: 'C:\Users bouf\OneDrive\Desktop\Deep_Learning\Training_Data\T\images'

大家好,

这是我在 python 中运行的代码的部分:

import os
import cv2
from PIL import Image
import numpy as np
from matplotlib import pyplot as plt
from patchify import patchify, unpatchify
import tifffile as tif
from sklearn.preprocessing import MinMaxScaler
from keras.optimizers import Adam

# import labels and images
large_image_stack = tif.imread(r"C:\Users\abouf\OneDrive\Desktop\Deep_Learning\Training_Data\T\images")
large_mask_stack = tif.imread(r"C:\Users\abouf\OneDrive\Desktop\Deep_Learning\Training_Data\T\labels")

all_img_patches = []

这是我收到的错误消息:

权限错误:[Errno 13] 权限被拒绝: 'C:\Users bouf\OneDrive\Desktop\Deep_Learning\Training_Data\T\images'

有人可以帮忙吗?谢谢你

python permissionerror
1个回答
0
投票

选项 1:尝试以管理员身份在命令提示符下运行 Python IDE(如 Anaconda、PyCharm 等)或脚本。

选项 2:作为测试,尝试将 TIF 文件复制到其他目录,例如 C:\Temp,然后看看是否可以从那里访问它们。

选项 3:确保没有其他应用程序正在使用您尝试访问的文件。关闭所有可能正在使用这些文件的应用程序。

选项 4:使用 os.listdir 检查目录,您可以列出目录中的文件以确保 Python 可以访问它:

import os

directory_path = r"C:\Users\abouf\OneDrive\Desktop\Deep_Learning\Training_Data\T\images"
print(os.listdir(directory_path))

谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.