OSError:使用ytree的文件不存在

2024-09-30 10:37:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一些数据需要使用ytree加载,可以通过以下方式完成:

import ytree

a = ytree.load('ctrees.h5')

但是,这样做会产生以下错误:

OSError: file does not exist: ctrees.h5.

使用回溯:

Traceback (most recent call last): 

File "C:\Users\Documents\untitled1.py", line 3, in <module>
a = ytree.load('ctrees.h5')

File "C:\Users\anaconda3\lib\site-packages\ytree\data_structures\arbor.py", line 1089, in load
raise IOError("file does not exist: %s." % filename)

OSError: file does not exist: ctrees.h5.

如果我尝试a=ytree.load(“ctrees.h5”),也会发生同样的情况。我可以看到该文件存在,我已将工作目录更改为正确的目录,并且我的脚本保存在同一目录中。我还尝试毫无乐趣地指定文件的完整路径。 我在Windows10上使用Python3.7和Ytree2.3

谢谢你的帮助

编辑(已解决): 通过在脚本顶部指定路径并将文件读取为,修复了此问题:

PATH='C:\\path\\to\\file\\directory\\'

a = ytree.load(PATH + "ctrees.h5")

Tags: 文件py目录linenotloadusersfile

热门问题