【问题标题】:How do you resolve the: FileNotFoundError: [Errno 2] No such file or directory:您如何解决: FileNotFoundError: [Errno 2] 没有这样的文件或目录:
【发布时间】:2021-09-16 12:44:23
【问题描述】:

你如何解决这个问题?使用 Python 对 Spyder 进行一些培训,我认为 Bitdefender 的阻止权限让我读取 Excel 文件。有谁知道如何授予权限?我不断收到相同的 FileNotFoundError

代码如下:

import pandas as pd
df = pd.read_excel(r'C:\Users\user\.spyder-py3\housing')
print(df)

返回为:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\.spyder-py3\\housing'

【问题讨论】:

  • 我看不到该文件的扩展名。可能是文件名类似于 Housing.xls 或 Housing.xlsx ,您必须首先找到真正的文件名。很可能你有一个寡妇设置不显示文件扩展名。
  • 为什么在你显示的代码中有user.spyder-py3时你的错误消息中有user\.spyder-py3

标签: python pandas spyder


【解决方案1】:

在路径中包含文件的扩展名(.xls.xlsx 等)

【讨论】:

  • 您似乎错过了 OP 使用 raw strings
  • 搞错了,谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-11-03
  • 2021-08-24
  • 2021-03-07
  • 2015-06-09
  • 2021-04-01
  • 2021-10-15
  • 1970-01-01
相关资源
最近更新 更多