# 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'
编辑:
如果我输入完整路径,它将正常工作:
with open(os.path.join('/home/wojtek/PycharmProjects/untitled3/venv/input/stage_2_train_labels.csv'), mode='r') as infile:
答案 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)
删除文件名的扩展名,应该很好!