为什么路径在PYTHONPATH中,文件仍未找到?

2024-10-02 02:43:10 发布

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

我有:

/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'

这是否仅适用于模块?你知道吗


Tags: 文件nogitmasterhomedataxmlworkspace
1条回答
网友
1楼 · 发布于 2024-10-02 02:43:10

是的,在此路径上搜索模块,请参见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的完整路径才能找到它(假定您不更改当前目录)。你知道吗

相关问题 更多 >

    热门问题