简体   繁体   English

FileNotFoundError: [Errno 2] 没有这样的文件或目录,复制路径名后

[英]FileNotFoundError: [Errno 2] No such file or directory, After copying pathname

x_train = []
for i in range(1, 4): 
    base_dir = f'/Users/name/Desktop/cancer_data/stage_1_png' #pathname that I copy-pasted
    files = os.listdir(base_dir)
    for file in tqdm(files):
        img = imread(base_dir+file)
        x_train.append(img)
x_train = np.array(x_train)
x_train.shape

I copy-pasted the pathname from the folder I want to extract images from, This same exact code was working before, but now I get the error message:我从要从中提取图像的文件夹中复制粘贴了路径名,以前可以使用相同的确切代码,但现在我收到错误消息:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/name/Desktop/cancer_data/stage_1_png'

check the filename again.再次检查文件名。 I think it should be stage_1.png instead of stage_1_png我认为应该是stage_1.png而不是stage_1_png

It is a relative path.这是一个相对路径。 I prefer to use r"".我更喜欢使用 r""。
shift + right click on the image file. shift + right click图像文件。 You will find a copy path option and use that instead of path.您将找到一个copy path选项并使用它代替路径。

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

相关问题 FileNotFoundError:[Errno 2]没有这样的文件或目录: - FileNotFoundError: [Errno 2] No such file or directory: FileNotFoundError [Errno 2] 没有这样的文件或目录: - FileNotFoundError [Errno 2] No such file or directory: FileNotFoundError: [Errno 2] 没有这样的文件或目录? - FileNotFoundError: [Errno 2] No such file or directory? FileNotFoundError:[错误2]没有这样的文件或目录,但是文件在那里 - FileNotFoundError: [Errno 2] No such file or directory, But the file is there FileNotFoundError: [Errno 2] 没有这样的文件或目录,但有一个文件 - FileNotFoundError: [Errno 2] No such file or directory but there is a file FileNotFoundError: [Errno 2] 没有这样的文件或目录:'ifconfig' - FileNotFoundError: [Errno 2] No such file or directory: 'ifconfig' 错误:FileNotFoundError:[Errno 2] 没有这样的文件或目录 - Bad: FileNotFoundError: [Errno 2] No such file or directory python:FileNotFoundError:[Errno 2]没有这样的文件或目录 - python: FileNotFoundError: [Errno 2] No such file or directory Python FileNotFoundError:[错误2]没有这样的文件或目录 - Python FileNotFoundError: [Errno 2] No such file or directory FileNotFoundError:[错误2]没有这样的文件或目录:错误 - FileNotFoundError: [Errno 2] No such file or directory: error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM