为什么我的Pycharm项目看不到文件夹? FileNotFoundError:[错误2]没有这样的文件或目录:'../input/stage_2_train_labels.csv'

时间:2018-12-18 13:39:56

标签: pycharm

# load table
with open(os.path.join('../input/stage_2_train_labels.csv'), mode='r') as infile:

我的Pycharm项目出错:FileNotFoundError: [Errno 2] No such file or directory: '../input/stage_2_train_labels.csv'

Pycharm Project

编辑: 如果我输入完整路径,它将正常工作: with open(os.path.join('/home/wojtek/PycharmProjects/untitled3/venv/input/stage_2_train_labels.csv'), mode='r') as infile:

2 个答案:

答案 0 :(得分:1)

如果我正确理解您的问题。您正在尝试从项目的根目录stage_2_train_labels.csv访问ww.py,而不必像在项目的根目录一样使用../

这应该更改

with open(os.path.join('../input/stage_2_train_labels.csv'), mode='r') as infile:

对此

with open(os.path.join('input/stage_2_train_labels.csv'), mode='r') as infile:

或者如果您尝试访问venv文件夹中的文件,请更改为

with open(os.path.join('venv/input/stage_2_train_labels.csv'), mode='r') as infile:

答案 1 :(得分:0)

删除文件名的扩展名,应该很好!