python错误提示:Errno 2] No such file or directory的解决方法
1、问题描述:
在学习北京大学曹健老师的tensorflow2.0笔记的时候,遇到了
[errno 2] no such file or directory: './mnist_image_label/mnist_train_jpg_60000.txt'
这个没有查找到子文件或者子文件夹的问题。
2、解决方法:
首先,确定所写的路径中包含相应的文件夹或者文件。
其次,如果文件名字或者路径没写错,查看自己是否使用相对路径(绝对路径一般不会报错),本次复现代码使用的ide是vscode,复习代码时出现这个错误的原因是我把,main.py的上级目录打开作为项目了,导致程序执行的时候是从上级目录开始查找所给路径,自然缺少当前目录的文件夹名,自然会报错。具体解释如下:
程序的路径设置:
正确的打开项目方式:
错误的打开项目方式:
3、小结:
可见错误的打开项目,导致我们在使用相对路径的时候需要在默认路径设置中添加当前文件夹名
即改为
train_path = './minist_fc/mnist_image_label/mnist_train_jpg_60000/'
如果前面的你都检查,代码一模一样没有问题,那么我建议你去检查一下你的文件了
大家看到这个文本有问题吗?猛地一看是不是哎呀没问题啊,再细看,你会发现,你多了一个后缀,为什么会这样呢?因为我们习惯的在后面加了一个txt后缀,但实际上它就是一个文本。所以好好检查自己的文件名
总结
到此这篇关于python错误提示:errno 2] no such file or directory的解决方法的文章就介绍到这了,更多相关python errno 2] no such file or directory内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
上一篇: Python详解文字转语音的实现
下一篇: Python教程教你如何去除背景
推荐阅读
-
Linux执行.sh文件,提示No such file or directory的问题的解决方法
-
Python提示[Errno 32]Broken pipe导致线程crash错误解决方法
-
win7系统提示错误80072ee2怎么办 win7系统无法更新总是提示错误80072ee2的解决方法
-
Win10蓝屏提示错误代码0x000000c2的解决方法
-
SublimeText 2编译python出错的解决方法(The system cannot find the file specified)
-
解决mongodb在ubuntu下启动失败,提示couldn‘t remove fs lock errno:9 Bad file descriptor的错误
-
mkdir()提示No such file or directory错误的解决方法
-
Linux执行可执行文件提示No such file or directory的解决方法
-
Django报错:python: can‘t open file ‘manage.py‘: [Errno 2] No such file or directory
-
python: can‘t open file ‘sqlmap.py‘: [Errno 2] No such file or directory