OSError:没有这样的文件或目录

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

当我尝试打开.h5文件时,它显示以下错误

Traceback (most recent call last):
  File "C:\Users\VW3ZTWS\PycharmProjects\Data_Collection_and_learnings\venv\lib\site-packages\IPython\core\interactiveshell.py", line 2869, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-10-524e5789c66b>", line 6, in <module>
    f = h5py.File(filename, 'r+')
  File "C:\Users\VW3ZTWS\PycharmProjects\Data_Collection_and_learnings\venv\lib\site-packages\h5py\_hl\files.py", line 394, in __init__
    swmr=swmr)
  File "C:\Users\VW3ZTWS\PycharmProjects\Data_Collection_and_learnings\venv\lib\site-packages\h5py\_hl\files.py", line 172, in make_fid
    fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5f.pyx", line 85, in h5py.h5f.open
OSError: Unable to open file (unable to open file: name = '28ggv-016.h5.h5', errno = 2, error message = 'No such file or directory', flags = 1, o_flags = 2)

我使用的代码:

import h5py
import numpy as np
import pandas as pd
filename = '28ggv-016.h5'
f = h5py.File(filename, 'r')
python python-3.x h5py
1个回答
1
投票

Ctrl + Shift + C复制文件的完整路径并将其粘贴到filename中:

import h5py
import numpy as np
import pandas as pd
filename = 'dir:\your\path\to\the\file\28ggv-016.h5'
f = h5py.File(filename, 'r')
© www.soinside.com 2019 - 2024. All rights reserved.