jupyterlab(https://jupyter.org/try-jupyter/lab/)的FilenotfoundError

发布于 2025-01-23 02:08:04 字数 299 浏览 0 评论 0 原文

Has anybody faced a FileNotFoundError in JupyterLab (https://jupyter.org/try-jupyter/lab/) when trying to read a .csv file? The file was uploaded in the same directory. I have used a CopyPath option to be sure that the path is correct. Still not working. Any suggestions on how can I fix this?

here is a snapshot of a simple code and an error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风追烟花雨 2025-01-30 02:08:04

这不太可能是Jupyter的错误。

确保 readfile.ipynb thefile.csv 在同一目录中。如果不是,请使用相对导入。

如果这仍然不起作用,请尝试以下Synthax。这与您提供的路径无关。

pd.read_csv(r'C:\Users\aiLab\Desktop\example.csv')

这里 r 是一个特殊的字符,意思是原始字符串。因此,将其前缀到您的字符串文字上。

::

python raw字符串是通过将字符串字面的字符串与'r'或
'r'。 Python Raw String将Backslash()视为字面角色。
当我们想要一个包含后斜拉的字符串时,这很有用
并且不希望将其视为逃生角色。

请参阅:

另外,请确保您没有不知不觉地复制一个看不见的角色。

This is unlikely to be an error with Jupyter.

Make sure that the ReadFile.ipynb and theFile.csv are in the same directory. If they are not, use a relative import.

enter image description here

If this still doesn't work, try the following synthax. This is independent of the path you provide.

pd.read_csv(r'C:\Users\aiLab\Desktop\example.csv')

Here r is a special character and means raw string. So prefix it to your string literal.

https://www.journaldev.com/23598/python-raw-string:

Python raw string is created by prefixing a string literal with ‘r’ or
‘R’. Python raw string treats backslash () as a literal character.
This is useful when we want to have a string that contains backslash
and don’t want it to be treated as an escape character.

See: pandas.read_csv FileNotFoundError: File b'\xe2\x80\xaa<etc>' despite correct path

Also, make sure that you don't have unwittingly copied an invisible character.

蓦然回首 2025-01-30 02:08:04

我遇到了同样的问题。
确保您的工作目录与笔记本和.CSV文件相同。通过运行 PWD 来检查此。您可以运行 ls 以获取工作目录中的文件列表。
如果这有助于您找到问题,请尝试完全关闭运行的内核并附加新的内核。这将更改工作目录。

I ran into the same problem.
Make sure your working directory is the same as your notebook and .csv file. Check this by running pwd. You can run ls to get the list of files in the working directory.
If this helps you find the problem, try shutting down the running kernel completely and attaching a new one. This will change the working directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文