简体   繁体   English

FileNotFoundError:[错误2]没有这样的文件或目录,但是文件在那里

[英]FileNotFoundError: [Errno 2] No such file or directory, But the file is there

Error Message says from the taskhandler.py : with open('./tasks.csv','r') as task_data: FileNotFoundError: [Errno 2] No such file or directory: './tasks.csv' 错误消息说,来自taskhandler.py:open('./ with open('./tasks.csv','r') as task_data: FileNotFoundError: [Errno 2] No such file or directory: './tasks.csv'

But it is actually there : 但实际上它在那里:

 . ├── feature │   ├── __init__.py │   ├── styles │   │   ├── __init__.py │   │   ├── termcolor.pyc │   │   ├── text_style.py │   ├── taskhandler.py │   └── tasks.csv ├── __init__.py ├── start.py 1 directories, 8 files 

Here is the code for the taskhandler.py 这是taskhandler.py的代码

...

def update_program(taskobj):
     with open('./tasks.csv','r') as task_data:
         csv_reader = csv.reader(task_data)

         next(csv_reader)

         for line in csv_reader:

             if line in taskobj:
                 pass
             else:
                 taskobj.append(line)

     task_data.close()

...

So how to get around this problem? 那么如何解决这个问题呢? Is there a mistake with the way i am openning the file? 我打开文件的方式有误吗? I tried it on my other computer and it works normally. 我在另一台计算机上尝试过,并且可以正常工作。

UPDATE 更新

Note : If you want to see the whole source code, go ahead to my github account or if you wanted to try the program and see the actual error, pip3 install pydotask and type in your terminal pydo . 注意:如果要查看整个源代码,请继续使用我的github帐户,或者如果要尝试该程序并查看实际错误,请pip3 install pydotask并输入终端pydo Some of the code and directory above are slightly edited and reconfigured in github and pip installation. 上面的一些代码和目录在github和pip安装中进行了稍微的编辑和重新配置。 But the problem remains the same. 但是问题仍然存在。

This is a CLI Program, so i suggest trying it with Linux. 这是一个CLI程序,所以我建议在Linux上尝试。

The csv file is in the same folder so you could try with open('tasks.csv','r') as task_data directly. csv文件位于同一文件夹中,因此您可以直接with open('tasks.csv','r') as task_data I hope this help you. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FileNotFoundError [Errno 2] 没有这样的文件或目录: - FileNotFoundError [Errno 2] No such file or directory: FileNotFoundError: [Errno 2] 没有这样的文件或目录? - FileNotFoundError: [Errno 2] No such file or directory? FileNotFoundError:[Errno 2]没有这样的文件或目录: - FileNotFoundError: [Errno 2] No such file or directory: FileNotFoundError: [Errno 2] 没有这样的文件或目录,但有一个文件 - FileNotFoundError: [Errno 2] No such file or directory but there is a file 获取“FileNotFoundError: [Errno 2] 没有这样的文件或目录” - Getting "FileNotFoundError: [Errno 2] No such file or directory" FileNotFoundError:[错误2]没有这样的文件或目录:'tesseract' - FileNotFoundError: [Errno 2] No such file or directory: 'tesseract' FileNotFoundError: [Errno 2] 没有这样的文件或目录:.netsh' - FileNotFoundError: [Errno 2] No such file or directory: 'netsh' 错误:FileNotFoundError:[Errno 2]没有这样的文件或目录: - Error: FileNotFoundError: [Errno 2] No such file or directory: FileNotFoundError: [Errno 2] 没有这样的文件或目录:'hadoop' - FileNotFoundError: [Errno 2] No such file or directory: 'hadoop' FileNotFoundError:[Errno 2] 没有这样的文件或目录:使用 csvreader - FileNotFoundError: [Errno 2] No such file or directory: with csvreader
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM