我正在尝试运行此 tutorial 中的代码。我已将代码和数据集放在同一目录中,但仍然收到以下错误。
FileNotFoundError Traceback (most recent call last)
<ipython-input-6-5f5284db0527> in <module>()
39 # extract features from all images
40 directory = 'Flicker8k'
---> 41 features = extract_features(directory)
42 print('Extracted Features: %d' % len(features))
43 # save to file
<ipython-input-6-5f5284db0527> in extract_features(directory)
18 # extract features from each photo
19 features = dict()
---> 20 for name in listdir(directory):
21 # load an image from file
22 filename = directory + '/' + name
**FileNotFoundError: [WinError 3] The system cannot find the path specified: 'Flicker8k'**
最佳答案
The system cannot find the path specified: 'Flicker8k'
它提示无法找到指定的目录。尝试将相对目录路径 directory = 'Flicker8k'
替换为 Flicker8k
目录的完整绝对路径(看起来就像您在 Windows 上一样,所以看起来像 C:\myproject\Flicker8k
或者如果您使用的是 Linux /home/user/myproject/Flicker8k
或该数据集所在的任何位置)。因此,请确保:
- 使用绝对路径而不是实际路径
- 文件夹(大小写正确)存在
- 数据集实际上位于该文件夹中
- 对文件夹(及其内的文件)的访问权限正常
关于python-3.x - 文件未找到错误: [WinError 3] The system cannot find the path specified:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51007476/