gpt4 book ai didi

python - 尽管路径在 PYTHONPATH 中,但为什么找不到该文件?

转载 作者:太空宇宙 更新时间:2023-11-03 15:52:07 33 4
gpt4 key购买 nike

我有:

/home/stefan/workspace/git/master-thesis/data

在 pythonpath 和一些位于以下位置的 XML 文件中设置:

/home/stefan/workspace/git/master-thesis/data/semeval/*.xml

但是,如果我尝试打开这些 XML 文件,我会收到:

FileNotFoundError: [Errno 2] No such file or directory: 'ABSA16_Restaurants_Train_SB1_v2.xml'

这只适用于模块吗?

最佳答案

是的,在此路径上搜索模块,请参阅documentation on PYTHONPATH :

Augment the default search path for module files. The format is the same as the shell’s PATH: one or more directory pathnames separated by os.pathsep (e.g. colons on Unix or semicolons on Windows). Non-existent directories are silently ignored.

您需要提供 open 的完整路径才能找到它(假设您不更改当前目录)。

关于python - 尽管路径在 PYTHONPATH 中,但为什么找不到该文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41192465/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com