python-3.x - 文件未找到错误: [WinError 3] The system cannot find the path specified:

标签 python-3.x machine-learning anaconda jupyter-notebook

我正在尝试运行此 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/

相关文章:

r - 无法通过 anaconda 在 Ubuntu 22.04 中安装最新版本的 Rstudio

python - 是否可以在 Enum 中定义类常量?

python - fmin_cg 函数用于最小化神经网络成本函数

r - 将稀疏矩阵 (dgCMatrix) 转换为 realRatingMatrix

python - 带有 Python 2.6 的 Anaconda Python

python - 使用特定列填充 Bokeh 中的工具提示

python - 在django查询集中动态定义过滤器参数

python - 在我的表单中使用MultipleFileField()时,FileRequiredValidator()不起作用

python - 无法从导入的模块中捕获 python 异常

python-3.x - 元素明智计算破坏了 autograd