python - OSError:没有这样的文件或目录
问题描述
当我尝试打开.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')
解决方案
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')
推荐阅读
- r - R中的ggmap和mapview包有问题吗?
- linux - Changing ansible loop due to v2.11 deprecation
- ios - Updating Menu Items In UIMenuController
- git - Git reflog expiration time
- javascript - Changing styles with delay
- python - 如何使 QSlider 不可点击
- azure - Azure Functions - how to set up IoTHubTrigger for my IoTHub messages?
- python - Python 3.7 单元测试期间异常部分的奇怪行为
- macos - 评估变量时VSCode调试器非常慢
- php - Select array values based on another array