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?
-
1This is an issue with the demo environment which runs entirely in the browser. There are workarounds described in: https://github.com/jupyterlite/jupyterlite/discussions/91 – krassowski Apr 20 '22 at 09:44
-
Also https://github.com/jupyterlite/jupyterlite/issues/119 and https://github.com/jupyterlite/jupyterlite/issues/199 – krassowski Apr 20 '22 at 09:46
-
Finally there is this experimental extension which bypasses the upload step altogether: https://github.com/jupyterlab-contrib/jupyterlab-filesystem-access – krassowski Apr 20 '22 at 09:49
-
@krassowski thanks a lot! I will dive into these resources and hope will find a workaround. – MaxiP Apr 20 '22 at 10:52
-
@MaxiP Also, if you want a full Python backed kernel experience like Try Jupyter used to offer, just go use the 'launch binder' badge at [the MyBinder JupyterLab demo example page](https://github.com/binder-examples/jupyterlab). – Wayne Apr 20 '22 at 19:09
2 Answers
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.
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.

- 88
- 5
-
Have tried both options. Files are in the same directory. Still not working...( Suppose that it is a problem with some settings of JupyterLab (web environment). I have tried to read a file in replit web environment and everything worked fine... Anyway, thank you for your help. – MaxiP Apr 20 '22 at 06:50
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.

- 66
- 1
- 6